git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Escape file:// URL's to meet subversion SVN::Ra requirements

From
Ben Walton <bwalton@artsci.utoronto.ca>
Date
Dec 17, 2011, 23:48 UTC
Message-ID
<1324165694-sup-8940@pinkfloyd.chass.utoronto.ca>
In-Reply-To
<20111217095019.GC8845@elie.hsd1.il.comcast.net>
Excerpts from Jonathan Nieder's message of Sat Dec 17 04:50:19 -0500 2011:
Hi Jonathan,

Thanks for following up on this. I've intermittently spent time digging away at it but other than a few poorly placed fixes that allowed me to get further into the test suite before failure, I haven't found a workable fix yet. I've included my wip patch below as it may help others that are more familiar with the workings of git-svn isolate a nice clean place to solve the problem.

Show 5 quoted lines
> The bad effect is that it converts percent signs to %25.  So
> commands like "git svn clone file:///path/to/test%20repository" that
> previously worked might not work any more, if v1.6.5-rc0~61 (svn:
> assume URLs from the command-line are URI-encoded, 2009-08-16) did
> not do its job completely.

I wonder if simply doing a uri decode followed by a uri encode might work? That would decode things that already had some encoding and then re-encode everything to handle a mixed encodings...I really think that the svn code should take 'raw' strings and encode internally but that ship has sailed.

> Another possible approach: to imitate the svn command line tools, we
> could use SVN::Client::url_from_path in some appropriate place.
I've been looking at these functions too.

Thanks -Ben

>From 98a6b6b4f26a644db5089fce68be6cf7261e4fe1 Mon Sep 17 00:00:00 2001
From: Ben Walton <bwalton@opencsw.org>
Date: Wed, 9 Nov 2011 02:39:05 +0100
Subject: [PATCH] selectively use svn functions to sanitize urls
Signed-off-by: Ben Walton <bwalton@opencsw.org>
---
 git-svn.perl |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 351e743..fb1ce65 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1342,9 +1342,13 @@ sub escape_uri_only {
 
 sub escape_url {
 	my ($url) = @_;
-	if ($url =~ m#^([^:]+)://([^/]*)(.*)$#) {
-		my ($scheme, $domain, $uri) = ($1, $2, escape_uri_only($3));
-		$url = "$scheme://$domain$uri";
+	if ($SVN::Core::VERSION =~ /^1\.[0-6]/) {
+		if ($url =~ m#^([^:]+)://([^/]*)(.*)$#) {
+			my ($scheme, $domain, $uri) = ($1, $2, escape_uri_only($3));
+			$url = "$scheme://$domain$uri";
+		}
+	} else {
+		$url = SVN::_Core::svn_uri_canonicalize($url);
 	}
 	$url;
 }
@@ -2222,7 +2226,7 @@ sub init_remote_config {
 					     "$url => $min_url\n";
 			}
 			my $old_path = $self->{path};
-			$self->{path} = $url;
+			$self->{path} = SVN::_Core::svn_uri_canonicalize($url);
 			$self->{path} =~ s!^\Q$min_url\E(/|$)!!;
 			if (length $old_path) {
 				$self->{path} .= "/$old_path";
@@ -5363,9 +5367,13 @@ sub escape_uri_only {
 
 sub escape_url {
 	my ($url) = @_;
-	if ($url =~ m#^(https?)://([^/]+)(.*)$#) {
-		my ($scheme, $domain, $uri) = ($1, $2, escape_uri_only($3));
-		$url = "$scheme://$domain$uri";
+	if ($SVN::Core::VERSION =~ /^1\.[0-6]/) {
+		if ($url =~ m#^(https?)://([^/]+)(.*)$#) {
+			my ($scheme, $domain, $uri) = ($1, $2, escape_uri_only($3));
+			$url = "$scheme://$domain$uri";
+		}
+	} else {
+		$url = SVN::_Core::svn_uri_canonicalize($url);
 	}
 	$url;
 }
-- 
1.7.6.1
--
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302
Previous: Jonathan Nieder
Message 11 of 11 in “(unknown)”
  1. Ben WaltonNov 2, 2011
  2. Escape file:// URL's to meet subversion SVN::Ra requirementsBen Walton, Nov 2, 2011
  3. Jonathan NiederNov 2, 2011
  4. Ben WaltonNov 2, 2011
  5. Eric WongNov 2, 2011
  6. Ben WaltonNov 4, 2011
  7. Jonathan NiederNov 4, 2011
  8. Michael WittenJul 16, 2012
  9. Jonathan NiederDec 17, 2011
  10. Jonathan NiederDec 17, 2011
  11. Ben WaltonDec 17, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.