From: Mike Fleetwood Date: Fri, 30 Aug 2013 21:35:20 +0000 (+0100) Subject: Fix shell quoting issues with the commit messages X-Git-Tag: 0.2~4 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=af857c1f0586de528f2d52b5b4fa340c52d7b8d6;p=rcs-fast-import.git Fix shell quoting issues with the commit messages 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 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 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. --- diff --git a/rcs-fast-import b/rcs-fast-import index 36272a6..7547ada 100755 --- a/rcs-fast-import +++ b/rcs-fast-import @@ -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):