Permalink
Browse files

Ignore extension for opened URLs unless they look legitimate

  • Loading branch information...
1 parent 9b42068 commit 84803907a5278b832f50be65524ebe20e0772c18 Garth Snyder committed Feb 2, 2011
Showing with 7 additions and 0 deletions.
  1. +1 −0 lib/mini_magick.rb
  2. +6 −0 test/image_test.rb
View
1 lib/mini_magick.rb
@@ -77,6 +77,7 @@ def open(file_or_url, ext = File.extname(file_or_url))
file_or_url = file_or_url.to_s # Force it to be a String... hell or highwater
if file_or_url.include?("://")
require 'open-uri'
+ ext = nil unless ext and ext =~ /^\.\w{2,8}$/
self.read(Kernel::open(file_or_url), ext)
else
File.open(file_or_url, "rb") do |f|
View
6 test/image_test.rb
@@ -57,6 +57,12 @@ def test_remote_image
image.destroy!
end
+ def test_remote_image_with_complex_url
+ image = Image.open("http://a0.twimg.com/a/1296609216/images/fronts/logo_withbird_home.png?extra=foo&plus=bar")
+ image.valid?
+ image.destroy!
+ end
+
def test_image_write
output_path = "output.gif"
begin

0 comments on commit 8480390

Please sign in to comment.