Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ignore extension for opened URLs unless they look legitimate

  • Loading branch information...
commit 84803907a5278b832f50be65524ebe20e0772c18 1 parent 9b42068
Garth Snyder authored
Showing with 7 additions and 0 deletions.
  1. +1 −0  lib/mini_magick.rb
  2. +6 −0 test/image_test.rb
1  lib/mini_magick.rb
View
@@ -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|
6 test/image_test.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.