Commit 85936c75 by Mike Burns

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

parents eadf7e82 cc89e4aa
......@@ -86,7 +86,7 @@ module Paperclip
# 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"
......
......@@ -155,6 +155,13 @@ class InterpolationsTest < Test::Unit::TestCase
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
zone = 'UTC'
......
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