Permalink
Browse files

Allow importing base64 strings without "=" padding.

  • Loading branch information...
1 parent c127288 commit 0c5f4f429828f17f9066da2f3ebba655ac58800b @martikaljuve martikaljuve committed Jun 11, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/chunky_png/canvas/data_url_importing.rb
@@ -10,7 +10,7 @@ module DataUrlImporting
# @raise ChunkyPNG::SignatureMismatch if the provides string is not a properly
# formatted PNG data URL (i.e. it should start with "data:image/png;base64,")
def from_data_url(string)
- if string =~ %r[^data:image/png;base64,((?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=))$]
+ if string =~ %r[^data:image/png;base64,((?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?)$]
from_blob($1.unpack('m').first)
else
raise SignatureMismatch, "The string was not a properly formatted data URL for a PNG image."

0 comments on commit 0c5f4f4

Please sign in to comment.