]> thyrsus.com Git - rcs-fast-import.git/commitdiff
Fix shell quoting issues with the commit messages
authorMike Fleetwood <mike.fleetwood@googlemail.com>
Fri, 30 Aug 2013 21:35:20 +0000 (22:35 +0100)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 3 Sep 2013 18:21:44 +0000 (14:21 -0400)
The commit message was subject to shell double quote expansion because
it was passed as a parameter to `ci' and external commands are executed
via a shell.  This could cause commit messages to be modified and to
even fail the import.  Single quote the commit message instead.

Test case:

$ cat test-03-comment-quoting.fastexp
commit refs/heads/master
mark :1
committer Joe Bloggs <joe.bloggs@example.com> 998655365 +0100
data 84
Commit message containing shell double quote special characters (`) ($HOME) and (')

M 644 inline file.txt
data 21
Contents of file.txt

$ rcs-fast-export -v -v -v < test-03-comment-quoting.fastexp
rcs-fast-import: repository fast import creates
/tmp/test/.rs24387
rcs-fast-import:......(0.00 sec) done.
commit refs/heads/master
rcs-fast-import:    :1 M file.txt
rcs-fast-import: linking ../.rs24387/inline-152187820 to file.txt
Assigning 1.1 to file.txt
rcs-fast-import: executing 'ci -l1.1 -d'Fri 24 Aug 2001 13:16:05 +0100'
-m"Committer: Joe Bloggs <joe.bloggs@example.com>
Committer-Date: Fri 24 Aug 2001 13:16:05 +0100
Mark: :1

Commit message containing shell double quote special characters (`) ($HOME) and (')
" file.txt RCS/file.txt,v' modify
/bin/sh: -c: line 4: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 6: syntax error: unexpected end of file
cleaning up......(0.00 sec) done.
rcs-fast-import: cleaning up
/tmp/test/.rs24387......(0.00 sec)
done.
rcs-fast-import: child returned 1.

rcs-fast-import

index 36272a669cbf6797dba6cba7beae1b5868dd1fa8..7547adaf263cf18edf737218283fcdc19a3f7c44 100755 (executable)
@@ -736,7 +736,7 @@ class RCS(Generic):
         if op == "D":
             command += " -sDeleted"
         command += " -d'%s'" % commit.committer.date.rfc822()
-        command += ' -m"%s"' % comment.replace('"', '\\"')
+        command += " -m'%s'" % comment.replace("'", "'\"'\"'")
         command += " " + path + " " + self.master(path)
         return command
     def checkout(self, path, branch):