Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: JRuby 1.6.7
-
Fix Version/s: None
-
Component/s: Core Classes/Modules
-
Labels:None
-
Number of attachments :
Description
When the input to Base64.strict_decode64() is actually not base64, then there should be an error raised, not the input silently discarded.
Expected:
> rvm ruby-1.9.3-p0-mri exec irb
1.9.3p0 :001 > require 'base64'
=> true
1.9.3p0 :002 > Base64.strict_decode64("%")
ArgumentError: invalid base64
Actual:
> rvm jruby-1.6.7 exec jruby --1.9 -S irb
jruby-1.6.7 :001 > require 'base64'
=> true
jruby-1.6.7 :002 > Base64.strict_decode64("%")
=> ""
This is actually an unpack bug with the "m0" specifier. strict_decode64 is implemented thus:
# Returns the Base64-decoded version of +str+. # This method complies with RFC 4648. # ArgumentError is raised if +str+ is incorrectly padded or contains # non-alphabet characters. Note that CR or LF are also rejected. def strict_decode64(str) str.unpack("m0").first end