Don't try and percent-escape existing percent escapes in git-svn URIs
PATCH 1/1 Don't try and percent-escape existing percent escapes in git-svn URIs
git-svn: project names are percent-escaped ever since f5530b. 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.
--- git-svn.perl | 2 +- t/t9120-git-svn-clone-with-percent-escapes.sh | 31 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletions(-) create mode 100755 t/t9120-git-svn-clone-with-percent-escapes.sh
git-svn.perl +1 -1
@@ -3658,7 +3658,7 @@ sub escape_uri_only { my ($uri) = @_; my @tmp; foreach (split m{/}, $uri) { - s/([^\w.-])/sprintf("%%%02X",ord($1))/eg; + s/([^\w.%-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg; push @tmp, $_; } join('/', @tmp);
t/t9120-git-svn-clone-with-percent-escapes.sh new file +31 -0
@@ -0,0 +1,31 @@ +#!/bin/sh +# +# Copyright (c) 2008 Kevin Ballard +# + +test_description='git-svn clone with percent escapes' +. ./lib-git-svn.sh + +test_expect_success 'setup svnrepo' " + mkdir project project/trunk project/branches project/tags && + echo foo > project/trunk/foo && + svn import -m '$test_description' project '$svnrepo/pr ject' && + rm -rf project && + start_httpd +" + +if test "$SVN_HTTPD_PORT" = "" +then + test_expect_failure 'test clone with percent escapes - needs SVN_HTTPD_PORT set' 'false' +else + test_expect_success 'test clone with percent escapes' ' + git svn clone "$svnrepo/pr%20ject" clone && + cd clone && + git rev-parse refs/remotes/git-svn && + cd .. + ' +fi + +stop_httpd + +test_done
Signature · 1 line
1.5.4.3.487.g1eab2.dirty
Quoted 4 lines · Kevin Ballard
git-svn: project names are percent-escaped ever since f5530b. 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.
What happens when something that _looks_ like a percent escape is actually a part of the URL and not really an escape?
Quoted 60 lines
Signed-off-by Kevin Ballard <[email protected]>--- git-svn.perl | 2 +- t/t9120-git-svn-clone-with-percent-escapes.sh | 31 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletions(-) create mode 100755 t/t9120-git-svn-clone-with-percent-escapes.shgit-svn.perl +1
-1@@ -3658,7 +3658,7 @@ sub escape_uri_only { my ($uri) = @_; my @tmp; foreach (split m{/}, $uri) { - s/([^\w.-])/sprintf("%%%02X",ord($1))/eg; + s/([^\w.%-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg; push @tmp, $_; } join('/', @tmp);t/t9120-git-svn-clone-with-percent-escapes.sh new file +31
-0@@ -0,0 +1,31 @@ +#!/bin/sh +# +# Copyright (c) 2008 Kevin Ballard +# + +test_description='git-svn clone with percent escapes' +. ./lib-git-svn.sh + +test_expect_success 'setup svnrepo' " + mkdir project project/trunk project/branches project/tags && + echo foo > project/trunk/foo && + svn import -m '$test_description' project '$svnrepo/pr ject' && + rm -rf project && + start_httpd +" + +if test "$SVN_HTTPD_PORT" = "" +then + test_expect_failure 'test clone with percent escapes - needs SVN_HTTPD_PORT set' 'false' +else + test_expect_success 'test clone with percent escapes' ' + git svn clone "$svnrepo/pr%20ject" clone && + cd clone && + git rev-parse refs/remotes/git-svn && + cd .. + ' +fi + +stop_httpd + +test_doneSignature · 1 line
1.5.4.3.487.g1eab2.dirty
Signature · 1 line
Eric Wong
Quoted 8 lines · Eric Wong
Quoted 4 lines · Kevin Ballard
git-svn: project names are percent-escaped ever since f5530b. 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.
What happens when something that _looks_ like a percent escape is actually a part of the URL and not really an escape?
Have you ever seen a URL like that? I haven't. However, what is fairly common is for URLs to contain spaces, and such URLs are always stored already-escaped.
The standard situation that triggers this issue is pulling a URL from svn info. Such a URL is already escaped, which means you can't feed it into git svn clone directly, you have to de-escape it first. This is a problem. Here's an example:
http://macromates.com/svn/Bundles/trunk/Bundles/Ruby%20on%20Rails.tmbundle
I tried cloning that and it failed, because it turned that into
http://macromates.com/svn/Bundles/trunk/Bundles/Ruby%2520on%2520Rails.tmbundle
However, my friend who was still on v1.5.3.7 cloned that no problem, since that was before the escaping code.
-Kevin
Quoted 67 lines
Quoted 63 lines
Signed-off-by Kevin Ballard <[email protected]>---
git-svn.perl | 2 +-t/t9120-git-svn-clone-with-percent-escapes.sh| 31 +++++++++++++++
++++++++++2 files changed, 32 insertions(+), 1 deletions(-)create mode 100755
t/t9120-git-svn-clone-with-percent-escapes.shgit-svn.perl +1
-1@@ -3658,7 +3658,7 @@ sub escape_uri_only { my ($uri) = @_; my @tmp; foreach (split m{/}, $uri) { - s/([^\w.-])/sprintf("%%%02X",ord($1))/eg; + s/([^\w.%-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg; push @tmp, $_; } join('/', @tmp);t/t9120-git-svn-clone-with-percent-escapes.sh new file +19
-0@@ -0,0 +1,31 @@ +#!/bin/sh +# +# Copyright (c) 2008 Kevin Ballard +# + +test_description='git-svn clone with percent escapes' +. ./lib-git-svn.sh + +test_expect_success 'setup svnrepo' " + mkdir project project/trunk project/branches project/tags && + echo foo > project/trunk/foo && + svn import -m '$test_description' project '$svnrepo/pr ject' && + rm -rf project && + start_httpd +" + +if test "$SVN_HTTPD_PORT" = "" +then + test_expect_failure 'test clone with percent escapes - needs
SVN_HTTPD_PORTset' 'false't/t9120-git-svn-clone-with-percent-escapes.sh new file +12
-0+else + test_expect_success 'test clone with percent escapes' ' + git svn clone "$svnrepo/pr%20ject" clone && + cd clone && + git rev-parse refs/remotes/git-svn && + cd .. + ' +fi + +stop_httpd + +test_doneSignature · 1 line
1.5.4.3.487.g1eab2.dirtySignature · 1 line
Eric Wong
Signature · 4 lines
Kevin Ballard http://kevin.sb.org [email protected] http://www.tildesoft.com
Quoted 8 lines · Kevin Ballard
Quoted 6 lines · Eric Wong
Quoted 4 lines · Kevin Ballard
git-svn: project names are percent-escaped ever since f5530b. 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.
Quoted 6 lines
Quoted 2 lines
What happens when something that _looks_ like a percent escape is actually a part of the URL and not really an escape?
Have you ever seen a URL like that? I haven't. However, what is fairly common is for URLs to contain spaces, and such URLs are always stored already-escaped.
No, but I wouldn't be surprised if they existed (as people are already crazy enough to put spaces in URLs).
Quoted 5 lines
The standard situation that triggers this issue is pulling a URL from
svn info. Such a URL is already escaped, which means you can't feed it intogit svn clonedirectly, you have to de-escape it first. This is a problem. Here's an example:
Quoted 8 lines
http://macromates.com/svn/Bundles/trunk/Bundles/Ruby%20on%20Rails.tmbundle
I tried cloning that and it failed, because it turned that into
http://macromates.com/svn/Bundles/trunk/Bundles/Ruby%2520on%2520Rails.tmbundle
However, my friend who was still on v1.5.3.7 cloned that no problem, since that was before the escaping code.
OK, I'll accept this. If they really want to represent '%', they should use "%25". But this should only be done for http/https URLs as svn(+ssh):// and file:// repositories aren't subject to the same rules http/https are.
Signature · 1 line
Eric Wong