lib/carrierwave/base64/base64_string_io.rb in carrierwave-base64-2.5.3 vs lib/carrierwave/base64/base64_string_io.rb in carrierwave-base64-2.6.0

- old
+ new

@@ -1,21 +1,16 @@ module Carrierwave module Base64 class Base64StringIO < StringIO - class ArgumentError < StandardError; end - attr_accessor :file_extension, :file_name def initialize(encoded_file, file_name) description, encoded_bytes = encoded_file.split(',') - raise ArgumentError unless encoded_bytes - raise ArgumentError if encoded_bytes.eql?('(null)') - @file_name = file_name @file_extension = get_file_extension description - bytes = ::Base64.decode64 encoded_bytes + bytes = ::Base64.strict_decode64 encoded_bytes super bytes end def original_filename @@ -26,10 +21,11 @@ def get_file_extension(description) content_type = description.split(';base64').first mime_type = MIME::Types[content_type].first unless mime_type - raise ArgumentError, "Unknown MIME type: #{content_type}" + raise Carrierwave::Base64::UnknownMimeTypeError, + "Unknown MIME type: #{content_type}" end mime_type.preferred_extension end end end