Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
bc093cf6
Commit
bc093cf6
authored
May 07, 2018
by
Roderick Monje
Committed by
Sid Raval
May 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle already encoded URLs
Closes
https://github.com/thoughtbot/paperclip/issues/2253
parent
b4e613b2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
5 deletions
+23
-5
lib/paperclip/io_adapters/http_url_proxy_adapter.rb
+2
-1
spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb
+21
-4
No files found.
lib/paperclip/io_adapters/http_url_proxy_adapter.rb
View file @
bc093cf6
...
...
@@ -9,7 +9,8 @@ module Paperclip
REGEXP
=
/\Ahttps?:\/\//
def
initialize
(
target
,
options
=
{})
super
(
URI
(
URI
.
escape
(
target
)),
options
)
escaped
=
URI
.
escape
(
target
)
super
(
URI
(
target
==
URI
.
unescape
(
target
)
?
escaped
:
target
),
options
)
end
end
end
spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb
View file @
bc093cf6
...
...
@@ -107,15 +107,32 @@ describe Paperclip::HttpUrlProxyAdapter do
end
context
"a url with special characters in the filename"
do
it
"returns a encoded filename"
do
before
do
Paperclip
::
HttpUrlProxyAdapter
.
any_instance
.
stubs
(
:download_content
).
returns
(
@open_return
)
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"
\
end
let
(
:filename
)
do
"paperclip-%C3%B6%C3%A4%C3%BC%E5%AD%97%C2%B4%C2%BD%E2%99%A5"
\
"%C3%98%C2%B2%C3%88.png"
end
let
(
:url
)
{
"https://github.com/thoughtbot/paperclip-öäü字´½♥زÈ.png"
}
subject
{
Paperclip
.
io_adapters
.
for
(
url
)
}
it
"returns a encoded filename"
do
assert_equal
filename
,
subject
.
original_filename
end
context
"when already URI encoded"
do
let
(
:url
)
do
"https://github.com/thoughtbot/paperclip-%C3%B6%C3%A4%C3%BC%E5%AD%97"
\
"%C2%B4%C2%BD%E2%99%A5%C3%98%C2%B2%C3%88.png"
end
it
"returns a encoded filename"
do
assert_equal
filename
,
subject
.
original_filename
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment