svn: properly escape arguments for authors-prog
Previously, the call to authors-prog was not properly escaped, so any special characters in the Subversion username, such as spaces and semi-colons, would be interpreted by the shell rather than being passed in as the first argument. Now all unsafe characters are escaped using "git rev-parse --sq-quote" [ew: switched from "\Q..\E" to "rev-parse --sq-quote"] Signed-off-by: Mark Lodato <lodatom@gmail.com> Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Mark Lodato committed
Sep 12, 2009 at 20:33 UTC
d3d7d47e6e0c3077fa39ffcca2b7f5f48ea97812
2 files changed
+15
git-svn.perl
+1
@@ -2810,6 +2810,7 @@ sub other_gs {
2810
2811
sub call_authors_prog {
2812
my ($orig_author) = @_;
2813
+ $orig_author = command_oneline('rev-parse', '--sq-quote', $orig_author);
2814
my $author = `$::_authors_prog $orig_author`;
2815
if ($? != 0) {
2816
die "$::_authors_prog failed with exit code $?\n"
t/t9138-git-svn-authors-prog.sh
+14
@@ -66,4 +66,18 @@ test_expect_success 'authors-file overrode authors-prog' '
66
)
67
'
68
69
+git --git-dir=x/.git config --unset svn.authorsfile
70
+git --git-dir=x/.git config --unset svn.authorsprog
71
+
72
+test_expect_success 'authors-prog handled special characters in username' '
73
+ svn mkdir -m bad --username "xyz; touch evil" "$svnrepo"/bad &&
74
+ (
75
+ cd x &&
76
+ git svn --authors-prog=../svn-authors-prog fetch &&
77
+ git rev-list -1 --pretty=raw refs/remotes/git-svn |
78
+ grep "^author xyz; touch evil <xyz; touch evil@example\.com> " &&
79
+ ! test -f evil
80
+ )
81
+'
82
+
83
test_done