{"thread":{"id":"12596","subject":"[PATCH] Don't try and percent-escape existing percent escapes in git-svn URIs","startedAt":"2008-03-08T23:20:47Z","lastAt":"2008-03-10T01:15:23Z","messageCount":4,"participants":["Kevin Ballard","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"71472","messageId":"1205018447-18344-1-git-send-email-kevin@sb.org","threadId":"12596","inReplyTo":null,"subject":"[PATCH] Don't try and percent-escape existing percent escapes in git-svn URIs","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2008-03-08T23:20:47Z","receivedAt":"2008-03-08T23:20:47Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"git-svn: project names are percent-escaped ever since f5530b.\nUnfortunately this breaks the scenario where the user hands git-svn\nan already-escaped URI. Fix the regexp to skip over what looks like\nexisting percent escapes, and test this scenario.\n\nSigned-off-by: Kevin Ballard <kevin@sb.org>\n---\n git-svn.perl                                  |    2 +-\n t/t9120-git-svn-clone-with-percent-escapes.sh |   31 +++++++++++++++++++++++++\n 2 files changed, 32 insertions(+), 1 deletions(-)\n create mode 100755 t/t9120-git-svn-clone-with-percent-escapes.sh\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 9e2faf9..cec664f 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -3658,7 +3658,7 @@ sub escape_uri_only {\n \tmy ($uri) = @_;\n \tmy @tmp;\n \tforeach (split m{/}, $uri) {\n-\t\ts/([^\\w.-])/sprintf(\"%%%02X\",ord($1))/eg;\n+\t\ts/([^\\w.%-]|%(?![a-fA-F0-9]{2}))/sprintf(\"%%%02X\",ord($1))/eg;\n \t\tpush @tmp, $_;\n \t}\n \tjoin('/', @tmp);\ndiff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/t9120-git-svn-clone-with-percent-escapes.sh\nnew file mode 100755\nindex 0000000..9a4eabe\n--- /dev/null\n+++ b/t/t9120-git-svn-clone-with-percent-escapes.sh\n@@ -0,0 +1,31 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Kevin Ballard\n+#\n+\n+test_description='git-svn clone with percent escapes'\n+. ./lib-git-svn.sh\n+\n+test_expect_success 'setup svnrepo' \"\n+\tmkdir project project/trunk project/branches project/tags &&\n+\techo foo > project/trunk/foo &&\n+\tsvn import -m '$test_description' project '$svnrepo/pr ject' &&\n+\trm -rf project &&\n+\tstart_httpd\n+\"\n+\n+if test \"$SVN_HTTPD_PORT\" = \"\"\n+then\n+\ttest_expect_failure 'test clone with percent escapes - needs SVN_HTTPD_PORT set' 'false'\n+else\n+\ttest_expect_success 'test clone with percent escapes' '\n+\t\tgit svn clone \"$svnrepo/pr%20ject\" clone &&\n+\t\tcd clone &&\n+\t\t\tgit rev-parse refs/remotes/git-svn &&\n+\t\tcd ..\n+\t'\n+fi\n+\n+stop_httpd\n+\n+test_done\n-- \n1.5.4.3.487.g1eab2.dirty\n\n"},{"id":"71496","messageId":"20080309091240.GA17484@mayonaise","threadId":"12596","inReplyTo":"1205018447-18344-1-git-send-email-kevin@sb.org","subject":"Re: [PATCH] Don't try and percent-escape existing percent escapes in git-svn URIs","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2008-03-09T09:12:40Z","receivedAt":"2008-03-09T09:12:40Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Kevin Ballard <kevin@sb.org> wrote:\n> git-svn: project names are percent-escaped ever since f5530b.\n> Unfortunately this breaks the scenario where the user hands git-svn\n> an already-escaped URI. Fix the regexp to skip over what looks like\n> existing percent escapes, and test this scenario.\n\nWhat happens when something that _looks_ like a percent escape is\nactually a part of the URL and not really an escape?\n\n> Signed-off-by: Kevin Ballard <kevin@sb.org>\n> ---\n>  git-svn.perl                                  |    2 +-\n>  t/t9120-git-svn-clone-with-percent-escapes.sh |   31 +++++++++++++++++++++++++\n>  2 files changed, 32 insertions(+), 1 deletions(-)\n>  create mode 100755 t/t9120-git-svn-clone-with-percent-escapes.sh\n> \n> diff --git a/git-svn.perl b/git-svn.perl\n> index 9e2faf9..cec664f 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -3658,7 +3658,7 @@ sub escape_uri_only {\n>  \tmy ($uri) = @_;\n>  \tmy @tmp;\n>  \tforeach (split m{/}, $uri) {\n> -\t\ts/([^\\w.-])/sprintf(\"%%%02X\",ord($1))/eg;\n> +\t\ts/([^\\w.%-]|%(?![a-fA-F0-9]{2}))/sprintf(\"%%%02X\",ord($1))/eg;\n>  \t\tpush @tmp, $_;\n>  \t}\n>  \tjoin('/', @tmp);\n> diff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/t9120-git-svn-clone-with-percent-escapes.sh\n> new file mode 100755\n> index 0000000..9a4eabe\n> --- /dev/null\n> +++ b/t/t9120-git-svn-clone-with-percent-escapes.sh\n> @@ -0,0 +1,31 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (c) 2008 Kevin Ballard\n> +#\n> +\n> +test_description='git-svn clone with percent escapes'\n> +. ./lib-git-svn.sh\n> +\n> +test_expect_success 'setup svnrepo' \"\n> +\tmkdir project project/trunk project/branches project/tags &&\n> +\techo foo > project/trunk/foo &&\n> +\tsvn import -m '$test_description' project '$svnrepo/pr ject' &&\n> +\trm -rf project &&\n> +\tstart_httpd\n> +\"\n> +\n> +if test \"$SVN_HTTPD_PORT\" = \"\"\n> +then\n> +\ttest_expect_failure 'test clone with percent escapes - needs SVN_HTTPD_PORT set' 'false'\n> +else\n> +\ttest_expect_success 'test clone with percent escapes' '\n> +\t\tgit svn clone \"$svnrepo/pr%20ject\" clone &&\n> +\t\tcd clone &&\n> +\t\t\tgit rev-parse refs/remotes/git-svn &&\n> +\t\tcd ..\n> +\t'\n> +fi\n> +\n> +stop_httpd\n> +\n> +test_done\n> -- \n> 1.5.4.3.487.g1eab2.dirty\n> \n\n-- \nEric Wong\n"},{"id":"71512","messageId":"0FE6BDE6-961E-4671-B9EC-EFA25389DF54@sb.org","threadId":"12596","inReplyTo":"20080309091240.GA17484@mayonaise","subject":"Re: [PATCH] Don't try and percent-escape existing percent escapes in git-svn URIs","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2008-03-09T12:29:09Z","receivedAt":"2008-03-09T12:29:09Z","isPatch":true,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"On Mar 9, 2008, at 5:12 AM, Eric Wong wrote:\n\n> Kevin Ballard <kevin@sb.org> wrote:\n>> git-svn: project names are percent-escaped ever since f5530b.\n>> Unfortunately this breaks the scenario where the user hands git-svn\n>> an already-escaped URI. Fix the regexp to skip over what looks like\n>> existing percent escapes, and test this scenario.\n>\n> What happens when something that _looks_ like a percent escape is\n> actually a part of the URL and not really an escape?\n\nHave you ever seen a URL like that? I haven't. However, what is fairly  \ncommon is for URLs to contain spaces, and such URLs are always stored  \nalready-escaped.\n\nThe standard situation that triggers this issue is pulling a URL from  \n`svn info`. Such a URL is already escaped, which means you can't feed  \nit into `git svn clone` directly, you have to de-escape it first. This  \nis a problem. Here's an example:\n\nhttp://macromates.com/svn/Bundles/trunk/Bundles/Ruby%20on%20Rails.tmbundle\n\nI tried cloning that and it failed, because it turned that into\n\nhttp://macromates.com/svn/Bundles/trunk/Bundles/Ruby%2520on%2520Rails.tmbundle\n\nHowever, my friend who was still on v1.5.3.7 cloned that no problem,  \nsince that was before the escaping code.\n\n-Kevin\n\n>\n>> Signed-off-by: Kevin Ballard <kevin@sb.org>\n>> ---\n>> git-svn.perl                                  |    2 +-\n>> t/t9120-git-svn-clone-with-percent-escapes.sh |   31 +++++++++++++++ \n>> ++++++++++\n>> 2 files changed, 32 insertions(+), 1 deletions(-)\n>> create mode 100755 t/t9120-git-svn-clone-with-percent-escapes.sh\n>>\n>> diff --git a/git-svn.perl b/git-svn.perl\n>> index 9e2faf9..cec664f 100755\n>> --- a/git-svn.perl\n>> +++ b/git-svn.perl\n>> @@ -3658,7 +3658,7 @@ sub escape_uri_only {\n>> \tmy ($uri) = @_;\n>> \tmy @tmp;\n>> \tforeach (split m{/}, $uri) {\n>> -\t\ts/([^\\w.-])/sprintf(\"%%%02X\",ord($1))/eg;\n>> +\t\ts/([^\\w.%-]|%(?![a-fA-F0-9]{2}))/sprintf(\"%%%02X\",ord($1))/eg;\n>> \t\tpush @tmp, $_;\n>> \t}\n>> \tjoin('/', @tmp);\n>> diff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/ \n>> t9120-git-svn-clone-with-percent-escapes.sh\n>> new file mode 100755\n>> index 0000000..9a4eabe\n>> --- /dev/null\n>> +++ b/t/t9120-git-svn-clone-with-percent-escapes.sh\n>> @@ -0,0 +1,31 @@\n>> +#!/bin/sh\n>> +#\n>> +# Copyright (c) 2008 Kevin Ballard\n>> +#\n>> +\n>> +test_description='git-svn clone with percent escapes'\n>> +. ./lib-git-svn.sh\n>> +\n>> +test_expect_success 'setup svnrepo' \"\n>> +\tmkdir project project/trunk project/branches project/tags &&\n>> +\techo foo > project/trunk/foo &&\n>> +\tsvn import -m '$test_description' project '$svnrepo/pr ject' &&\n>> +\trm -rf project &&\n>> +\tstart_httpd\n>> +\"\n>> +\n>> +if test \"$SVN_HTTPD_PORT\" = \"\"\n>> +then\n>> +\ttest_expect_failure 'test clone with percent escapes - needs  \n>> SVN_HTTPD_PORT set' 'false'\n>> +else\n>> +\ttest_expect_success 'test clone with percent escapes' '\n>> +\t\tgit svn clone \"$svnrepo/pr%20ject\" clone &&\n>> +\t\tcd clone &&\n>> +\t\t\tgit rev-parse refs/remotes/git-svn &&\n>> +\t\tcd ..\n>> +\t'\n>> +fi\n>> +\n>> +stop_httpd\n>> +\n>> +test_done\n>> -- \n>> 1.5.4.3.487.g1eab2.dirty\n>>\n>\n> -- \n> Eric Wong\n>\n\n-- \nKevin Ballard\nhttp://kevin.sb.org\nkevin@sb.org\nhttp://www.tildesoft.com\n\n\n"},{"id":"71544","messageId":"20080310011523.GB17484@mayonaise","threadId":"12596","inReplyTo":"0FE6BDE6-961E-4671-B9EC-EFA25389DF54@sb.org","subject":"Re: [PATCH] Don't try and percent-escape existing percent escapes in git-svn URIs","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2008-03-10T01:15:23Z","receivedAt":"2008-03-10T01:15:23Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Kevin Ballard <kevin@sb.org> wrote:\n> On Mar 9, 2008, at 5:12 AM, Eric Wong wrote:\n> \n> >Kevin Ballard <kevin@sb.org> wrote:\n> >>git-svn: project names are percent-escaped ever since f5530b.\n> >>Unfortunately this breaks the scenario where the user hands git-svn\n> >>an already-escaped URI. Fix the regexp to skip over what looks like\n> >>existing percent escapes, and test this scenario.\n> >\n> >What happens when something that _looks_ like a percent escape is\n> >actually a part of the URL and not really an escape?\n> \n> Have you ever seen a URL like that? I haven't. However, what is fairly  \n> common is for URLs to contain spaces, and such URLs are always stored  \n> already-escaped.\n\nNo, but I wouldn't be surprised if they existed (as people are already\ncrazy enough to put spaces in URLs).\n\n> The standard situation that triggers this issue is pulling a URL from  \n> `svn info`. Such a URL is already escaped, which means you can't feed  \n> it into `git svn clone` directly, you have to de-escape it first. This  \n> is a problem. Here's an example:\n> \n> http://macromates.com/svn/Bundles/trunk/Bundles/Ruby%20on%20Rails.tmbundle\n> \n> I tried cloning that and it failed, because it turned that into\n> \n> http://macromates.com/svn/Bundles/trunk/Bundles/Ruby%2520on%2520Rails.tmbundle\n> \n> However, my friend who was still on v1.5.3.7 cloned that no problem,  \n> since that was before the escaping code.\n\nOK, I'll accept this.  If they really want to represent '%', they should\nuse \"%25\".  But this should only be done for http/https URLs as\nsvn(+ssh):// and file:// repositories aren't subject to the same rules\nhttp/https are.\n\n-- \nEric Wong\n"}]}