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
85c65d3d
Commit
85c65d3d
authored
Jul 27, 2010
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A real check for infinite loops in the :url interpolation.
parent
9223a917
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
5 deletions
+7
-5
lib/paperclip/interpolations.rb
+1
-1
lib/paperclip/storage.rb
+0
-1
test/interpolations_test.rb
+6
-3
No files found.
lib/paperclip/interpolations.rb
View file @
85c65d3d
...
...
@@ -42,7 +42,7 @@ module Paperclip
# contains ":url" to prevent infinite recursion. This interpolation
# is used in the default :path to ease default specifications.
def
url
attachment
,
style_name
raise
InfiniteInterpolationError
if
attachment
.
options
[
:url
].
include?
(
":url"
)
raise
InfiniteInterpolationError
if
caller
.
any?
{
|
b
|
b
.
index
(
"
#{
__FILE__
}
:
#{
__LINE__
+
1
}
"
)
}
attachment
.
url
(
style_name
,
false
)
end
...
...
lib/paperclip/storage.rb
View file @
85c65d3d
...
...
@@ -144,7 +144,6 @@ module Paperclip
@s3_headers
=
@options
[
:s3_headers
]
||
{}
@s3_host_alias
=
@options
[
:s3_host_alias
]
unless
@url
.
to_s
.
match
(
/^:s3.*url$/
)
@path
=
@url
@url
=
":s3_path_url"
end
AWS
::
S3
::
Base
.
establish_connection!
(
@s3_options
.
merge
(
...
...
test/interpolations_test.rb
View file @
85c65d3d
...
...
@@ -82,14 +82,17 @@ class InterpolationsTest < Test::Unit::TestCase
should
"reinterpolate :url"
do
attachment
=
mock
attachment
.
expects
(
:options
).
returns
({
:url
=>
":id"
})
attachment
.
expects
(
:url
).
with
(
:style
,
false
).
returns
(
"1234"
)
assert_equal
"1234"
,
Paperclip
::
Interpolations
.
url
(
attachment
,
:style
)
end
should
"raise if infinite loop detcted reinterpolating :url"
do
attachment
=
mock
attachment
.
expects
(
:options
).
returns
({
:url
=>
":url"
})
attachment
=
Object
.
new
class
<<
attachment
def
url
(
*
args
)
Paperclip
::
Interpolations
.
url
(
self
,
:style
)
end
end
assert_raises
(
Paperclip
::
InfiniteInterpolationError
){
Paperclip
::
Interpolations
.
url
(
attachment
,
:style
)
}
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