Skip to content

Commit

Permalink
Fix detection of base64 encoded files with complex MIME type
Browse files Browse the repository at this point in the history
  • Loading branch information
const-cloudinary committed May 27, 2024
1 parent 184580a commit d36b7dc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cloudinary/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Cloudinary::Utils
zoom
].map(&:to_sym)

REMOTE_URL_REGEX = %r(^ftp:|^https?:|^s3:|^gs:|^data:([\w-]+\/[\w-]+(\+[\w-]+)?)?(;[\w-]+=[\w-]+)*;base64,([a-zA-Z0-9\/+\n=]+)$)
REMOTE_URL_REGEX = %r(^ftp:|^https?:|^s3:|^gs:|^data:([\w-]+\/[\w-]+(\.[\w-]+)*(\+[\w-]+)?)?(;[\w-]+=[\w-]+)*;base64,([a-zA-Z0-9\/+\n=]+)$)

LONG_URL_SIGNATURE_LENGTH = 32
SHORT_URL_SIGNATURE_LENGTH = 8
Expand Down
1 change: 1 addition & 0 deletions spec/utils_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"data:image/gif;charset=utf8;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
"data:image/gif;param1=value1;param2=value2;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
"data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg",
"data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg",
].each do |url|
expect(Cloudinary::Utils.is_remote?(url)).to eq(true), url
end
Expand Down

0 comments on commit d36b7dc

Please sign in to comment.