@@ -40,7 +40,7 @@ def file
4040 headers = @remote_headers .
4141 reverse_merge ( 'User-Agent' => "CarrierWave/#{ CarrierWave ::VERSION } " )
4242
43- @file = Kernel . open ( @uri . to_s , headers )
43+ @file = URI . open ( @uri . to_s , headers )
4444 @file = @file . is_a? ( String ) ? StringIO . new ( @file ) : @file
4545 end
4646 @file
@@ -57,7 +57,7 @@ def filename_from_header
5757 end
5858
5959 def filename_from_uri
60- URI . decode ( File . basename ( file . base_uri . path ) )
60+ URI :: DEFAULT_PARSER . unescape ( File . basename ( file . base_uri . path ) )
6161 end
6262
6363 def method_missing ( *args , &block )
@@ -92,8 +92,8 @@ def process_uri(uri)
9292 rescue URI ::InvalidURIError
9393 uri_parts = uri . split ( '?' )
9494 # regexp from Ruby's URI::Parser#regexp[:UNSAFE], with [] specifically removed
95- encoded_uri = URI . encode ( uri_parts . shift , /[^\- _.!~*'()a-zA-Z\d ;\/ ?:@&=+$,]/ )
96- encoded_uri << '?' << URI . encode ( uri_parts . join ( '?' ) ) if uri_parts . any?
95+ encoded_uri = URI :: DEFAULT_PARSER . unescape ( uri_parts . shift , /[^\- _.!~*'()a-zA-Z\d ;\/ ?:@&=+$,]/ )
96+ encoded_uri << '?' << URI :: DEFAULT_PARSER . unescape ( uri_parts . join ( '?' ) ) if uri_parts . any?
9797 URI . parse ( encoded_uri ) rescue raise CarrierWave ::DownloadError , "couldn't parse URL"
9898 end
9999
0 commit comments