[Rubygems-developers] 1.3.2?

Daniel Berger djberg96 at gmail.com
Fri Mar 20 23:52:07 EDT 2009


Luis Lavena wrote:

<snip>

>>>
>>> The idea was test path with spaces, like Windows paths? because Ruby
>>> URI is not recognizing it as a file source URI.
>>>
>>> Or I'm missing something?
>> The idea was to test (at least) installing from a space path.  My idea was
>> to URI encode the path first to make the spaces palatable.  This at least
>> works for OS X, maybe the drive letter is confusing it and it needs extra
>> escaping?
> 
> I think for D:/Some/Path/with spaces/ requires to be prepend with
> file:// protocol :-D
> 
> Something like this:
> 
> file:///D:/Some/path/with%20spaces/

I think always escaping the URI is the better solution:

--- remote_fetcher.old  Fri Mar 20 21:37:44 2009
+++ remote_fetcher.rb   Fri Mar 20 21:38:30 2009
@@ -85,17 +85,12 @@
     local_gem_path = File.join cache_dir, gem_file_name

     FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir
+
+    # Always escape URI's to deal with potential spaces and such
     unless URI::Generic === source_uri
-      begin
-        source_uri = URI.parse source_uri
-      rescue URI::InvalidURIError
-        if source_uri =~ /\A#{File::SEPARATOR}/o then # HACK mswin
-          source_uri = URI.parse URI.escape(source_uri)
-        else
-          raise
-        end
-      end
+      source_uri = URI.parse(URI.escape(source_uri))
     end
+
     scheme = source_uri.scheme

     # URI.parse gets confused by MS Windows paths with forward slashes.

All tests pass.

Unless anyone has any objections, I'm going to commit this at some point 
this weekend.

Regards,

Dan



More information about the Rubygems-developers mailing list