Skip to content

Commit

Permalink
Merge pull request #2462 from aubinlrx/tweak/deprecation_warning_ruby_27
Browse files Browse the repository at this point in the history
[1.x-stable] - Fix deprecation warning ruby 2.7
  • Loading branch information
mshibuya committed Oct 4, 2020
2 parents c3c652a + 6097836 commit 0712435
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/carrierwave/sanitized_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def file=(file)
def mkdir!(path, directory_permissions)
options = {}
options[:mode] = directory_permissions if directory_permissions
FileUtils.mkdir_p(File.dirname(path), options) unless File.exist?(File.dirname(path))
FileUtils.mkdir_p(File.dirname(path), **options) unless File.exist?(File.dirname(path))
end

def chmod!(path, permissions)
Expand Down
8 changes: 4 additions & 4 deletions lib/carrierwave/uploader/download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def file
headers = @remote_headers.
reverse_merge('User-Agent' => "CarrierWave/#{CarrierWave::VERSION}")

@file = Kernel.open(@uri.to_s, headers)
@file = URI.open(@uri.to_s, headers)
@file = @file.is_a?(String) ? StringIO.new(@file) : @file
end
@file
Expand All @@ -57,7 +57,7 @@ def filename_from_header
end

def filename_from_uri
URI.decode(File.basename(file.base_uri.path))
URI::DEFAULT_PARSER.unescape(File.basename(file.base_uri.path))
end

def method_missing(*args, &block)
Expand Down 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.encode(uri_parts.shift, /[^\-_.!~*'()a-zA-Z\d;\/?:@&=+$,]/)
encoded_uri << '?' << URI.encode(uri_parts.join('?')) if uri_parts.any?
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?
URI.parse(encoded_uri) rescue raise CarrierWave::DownloadError, "couldn't parse URL"
end

Expand Down

0 comments on commit 0712435

Please sign in to comment.