Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/iainbeeston/paperclip

  • Loading branch information...
commit 85936c753ddbf3dda1b68c707e9ceaeaaebea2a5 2 parents eadf7e8 + cc89e4a
@mike-burns mike-burns authored
Showing with 8 additions and 1 deletion.
  1. +1 −1  lib/paperclip/interpolations.rb
  2. +7 −0 test/interpolations_test.rb
View
2  lib/paperclip/interpolations.rb
@@ -86,7 +86,7 @@ def class attachment = nil, style_name = nil
# Returns the basename of the file. e.g. "file" for "file.jpg"
def basename attachment, style_name
- attachment.original_filename.gsub(/#{File.extname(attachment.original_filename)}$/, "")
+ attachment.original_filename.gsub(/#{Regexp.escape(File.extname(attachment.original_filename))}$/, "")
end
# Returns the extension of the file. e.g. "jpg" for "file.jpg"
View
7 test/interpolations_test.rb
@@ -154,6 +154,13 @@ def url(*args)
attachment.stubs(:original_filename).returns("one")
assert_equal "one", Paperclip::Interpolations.filename(attachment, :style)
end
+
+ should "return the basename when the extension contains regexp special characters" do
+ attachment = mock
+ attachment.stubs(:styles).returns({})
+ attachment.stubs(:original_filename).returns("one.ab)")
+ assert_equal "one", Paperclip::Interpolations.basename(attachment, :style)
+ end
should "return the timestamp" do
now = Time.now
Please sign in to comment.
Something went wrong with that request. Please try again.