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
f1d06898
Commit
f1d06898
authored
Jun 12, 2014
by
caneroj1
Committed by
Jon Yurek
Aug 29, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addressed issue #1324 for URL escaping of (, ), [, and ] characters.
parent
35f0005f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletions
+14
-1
lib/paperclip/url_generator.rb
+1
-1
spec/paperclip/url_generator_spec.rb
+13
-0
No files found.
lib/paperclip/url_generator.rb
View file @
f1d06898
...
...
@@ -58,7 +58,7 @@ module Paperclip
end
def
escape_url
(
url
)
(
url
.
respond_to?
(
:escape
)
?
url
.
escape
:
URI
.
escape
(
url
)).
gsub
(
/(\/.+)\?(.+\.)/
,
'\1%3F\2'
)
(
url
.
respond_to?
(
:escape
)
?
url
.
escape
:
URI
.
escape
(
url
)).
gsub
(
/(\/.+)\?(.+\.)/
,
'\1%3F\2'
)
.
gsub
(
/\(/
,
'%28'
).
gsub
(
/\)/
,
'%29'
).
gsub
(
/\[/
,
'%5B'
).
gsub
(
/\]/
,
'%5D'
)
end
end
end
spec/paperclip/url_generator_spec.rb
View file @
f1d06898
...
...
@@ -183,4 +183,17 @@ describe Paperclip::UrlGenerator do
assert
mock_interpolator
.
has_interpolated_pattern?
(
expected
),
"expected the interpolator to be passed
#{
expected
.
inspect
}
but it wasn't"
end
it
"should be able to escape (, ), [, and ]."
do
expected
=
"the(expected)result[]"
mock_attachment
=
MockAttachment
.
new
mock_interpolator
=
MockInterpolator
.
new
(
result:
expected
)
options
=
{
interpolator:
mock_interpolator
}
url_generator
=
Paperclip
::
UrlGenerator
.
new
(
mock_attachment
,
options
)
def
url_generator
.
respond_to
(
params
)
false
if
params
==
:escape
end
result
=
url_generator
.
for
(
:style_name
,
{
escape:
true
})
assert_equal
"the%28expected%29result%5B%5D"
,
result
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