Skip to content

Commit 8114da1

Browse files
lilyballgitster
authored andcommitted
Don't try and percent-escape existing percent escapes in git-svn URIs
git-svn project names are percent-escaped ever since f5530b8 (git-svn: support for funky branch and project names over HTTP(S), 2007-11-11). Unfortunately this breaks the scenario where the user hands git-svn an already-escaped URI. Fix the regexp to skip over what looks like existing percent escapes, and test this scenario. Signed-off-by: Kevin Ballard <kevin@sb.org> Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 740fdd2 commit 8114da1

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

git-svn.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3665,7 +3665,7 @@ sub escape_uri_only {
36653665
my ($uri) = @_;
36663666
my @tmp;
36673667
foreach (split m{/}, $uri) {
3668-
s/([^\w.-])/sprintf("%%%02X",ord($1))/eg;
3668+
s/([^\w.%-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg;
36693669
push @tmp, $_;
36703670
}
36713671
join('/', @tmp);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2008 Kevin Ballard
4+
#
5+
6+
test_description='git-svn clone with percent escapes'
7+
. ./lib-git-svn.sh
8+
9+
test_expect_success 'setup svnrepo' "
10+
mkdir project project/trunk project/branches project/tags &&
11+
echo foo > project/trunk/foo &&
12+
svn import -m '$test_description' project '$svnrepo/pr ject' &&
13+
rm -rf project &&
14+
start_httpd
15+
"
16+
17+
if test "$SVN_HTTPD_PORT" = ""
18+
then
19+
test_expect_failure 'test clone with percent escapes - needs SVN_HTTPD_PORT set' 'false'
20+
else
21+
test_expect_success 'test clone with percent escapes' '
22+
git svn clone "$svnrepo/pr%20ject" clone &&
23+
cd clone &&
24+
git rev-parse refs/remotes/git-svn &&
25+
cd ..
26+
'
27+
fi
28+
29+
stop_httpd
30+
31+
test_done

0 commit comments

Comments
 (0)