Skip to content

Commit d3d7d47

Browse files
MarkLodatogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 45c58ba commit d3d7d47

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

git-svn.perl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,6 +2810,7 @@ sub other_gs {
28102810

28112811
sub call_authors_prog {
28122812
my ($orig_author) = @_;
2813+
$orig_author = command_oneline('rev-parse', '--sq-quote', $orig_author);
28132814
my $author = `$::_authors_prog $orig_author`;
28142815
if ($? != 0) {
28152816
die "$::_authors_prog failed with exit code $?\n"

t/t9138-git-svn-authors-prog.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,18 @@ test_expect_success 'authors-file overrode authors-prog' '
6666
)
6767
'
6868

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+
6983
test_done

0 commit comments

Comments
 (0)