Commit dfd73b3e by Piotr Szal Committed by Tute Costa

Saving images from url with special characters #1921

[fixes #1932]
parent 0675822e
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Bugfix: Dynamic fog directory option is now respected * Bugfix: Dynamic fog directory option is now respected
* Bugfix: Fixes cocaine duplicated paths [#2169] * Bugfix: Fixes cocaine duplicated paths [#2169]
* Bugfix: Now it's possible to save images from URLs with special characters [#1932]
* Removal of dead code (older versions of Rails and AWS SDK) * Removal of dead code (older versions of Rails and AWS SDK)
* README adjustments * README adjustments
......
...@@ -4,7 +4,7 @@ module Paperclip ...@@ -4,7 +4,7 @@ module Paperclip
REGEXP = /\Ahttps?:\/\// REGEXP = /\Ahttps?:\/\//
def initialize(target) def initialize(target)
super(URI(target)) super(URI(URI.escape(target)))
end end
end end
......
...@@ -98,4 +98,16 @@ describe Paperclip::HttpUrlProxyAdapter do ...@@ -98,4 +98,16 @@ describe Paperclip::HttpUrlProxyAdapter do
end end
end end
context "a url with special characters in the filename" do
it "returns a encoded filename" do
Paperclip::HttpUrlProxyAdapter.any_instance.stubs(:download_content).
returns(StringIO.new("x"))
url = "https://github.com/thoughtbot/paperclip-öäü字´½♥زÈ.png"
subject = Paperclip.io_adapters.for(url)
filename = "paperclip-%C3%B6%C3%A4%C3%BC%E5%AD%97%C2%B4%C2%BD%E2%99%A5"\
"%C3%98%C2%B2%C3%88.png"
assert_equal filename, subject.original_filename
end
end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment