{"thread":{"id":"16706","subject":"[PATCH] \"git svn clone\" fails when tags have illegal url characters in them.","startedAt":"2008-12-12T22:46:38Z","lastAt":"2008-12-12T22:46:38Z","messageCount":1,"participants":["Jerry Seutter"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"97758","messageId":"2c8d48d70812121446m7539a054p86588488d77302f4@mail.gmail.com","threadId":"16706","inReplyTo":null,"subject":"[PATCH] \"git svn clone\" fails when tags have illegal url characters in them.","fromName":"Jerry Seutter","fromEmail":"jseutter@gmail.com","sentAt":"2008-12-12T22:46:38Z","receivedAt":"2008-12-12T22:46:38Z","isPatch":true,"sender":{"key":"jseutter@gmail.com","avatar":null},"body":"Found a repository with a tag that had a hash (#) mark in the tag name.\nThe svn repository was available via WebDAV. \"git svn clone <url>\" would\ngenerate an invalid url when trying to fetch the tag, causing a server\n400 result on the other end of the connection.\n\nThe fix is to escape the url correctly.  This is a quick and dirty\nhack that copies two functions from earlier in the file - only the last\nline modified in the commit is important.\n\nSigned-off-by: Jerry Seutter <jseutter@gmail.com>\n---\n git-svn.perl |   21 ++++++++++++++++++++-\n 1 files changed, 20 insertions(+), 1 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 2c206e9..6b9e010 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2213,9 +2213,28 @@ sub metadata_url {\n \t   (length $self->{path} ? '/' . $self->{path} : '');\n }\n\n+sub junk_escape_uri_only {\n+\tmy ($uri) = @_;\n+\tmy @tmp;\n+\tforeach (split m{/}, $uri) {\n+\t\ts/([^~\\w.%+-]|%(?![a-fA-F0-9]{2}))/sprintf(\"%%%02X\",ord($1))/eg;\n+\t\tpush @tmp, $_;\n+\t}\n+\tjoin('/', @tmp);\n+}\n+\n+sub junk_escape_url {\n+\tmy ($url) = @_;\n+\tif ($url =~ m#^([^:]+)://([^/]*)(.*)$#) {\n+\t\tmy ($scheme, $domain, $uri) = ($1, $2, junk_escape_uri_only($3));\n+\t\t$url = \"$scheme://$domain$uri\";\n+\t}\n+\t$url;\n+}\n+\n sub full_url {\n \tmy ($self) = @_;\n-\t$self->{url} . (length $self->{path} ? '/' . $self->{path} : '');\n+\tjunk_escape_url($self->{url} . (length $self->{path} ? '/' .\n$self->{path} : ''));\n }\n\n\n-- \n1.6.1.rc2.20.gde0d.dirty\n"}]}