Skip to content

Commit

Permalink
URI.encode becomes escape, not unescape
Browse files Browse the repository at this point in the history
Refs. #2462
  • Loading branch information
mshibuya committed Oct 5, 2020
1 parent 0712435 commit ac3d006
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/carrierwave/uploader/download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def process_uri(uri)
rescue URI::InvalidURIError
uri_parts = uri.split('?')
# regexp from Ruby's URI::Parser#regexp[:UNSAFE], with [] specifically removed
encoded_uri = URI::DEFAULT_PARSER.unescape(uri_parts.shift, /[^\-_.!~*'()a-zA-Z\d;\/?:@&=+$,]/)
encoded_uri << '?' << URI::DEFAULT_PARSER.unescape(uri_parts.join('?')) if uri_parts.any?
encoded_uri = URI::DEFAULT_PARSER.escape(uri_parts.shift, /[^\-_.!~*'()a-zA-Z\d;\/?:@&=+$,]/)
encoded_uri << '?' << URI::DEFAULT_PARSER.escape(uri_parts.join('?')) if uri_parts.any?
URI.parse(encoded_uri) rescue raise CarrierWave::DownloadError, "couldn't parse URL"
end

Expand Down

0 comments on commit ac3d006

Please sign in to comment.