Skip to content

Commit

Permalink
Changed the sanitization a little.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed Jun 9, 2008
1 parent e0c9d64 commit 311732b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/paperclip/attachment.rb
Expand Up @@ -58,7 +58,7 @@ def assign uploaded_file
return nil if uploaded_file.nil? return nil if uploaded_file.nil?


@queued_for_write[:original] = uploaded_file.to_tempfile @queued_for_write[:original] = uploaded_file.to_tempfile
@instance[:"#{@name}_file_name"] = uploaded_file.original_filename.strip.gsub /[^A-Za-z0-9\.]/, '_' @instance[:"#{@name}_file_name"] = uploaded_file.original_filename.strip.gsub /[^\w\d\.\-]+/, '_'
@instance[:"#{@name}_content_type"] = uploaded_file.content_type.strip @instance[:"#{@name}_content_type"] = uploaded_file.content_type.strip
@instance[:"#{@name}_file_size"] = uploaded_file.size.to_i @instance[:"#{@name}_file_size"] = uploaded_file.size.to_i


Expand Down
2 changes: 1 addition & 1 deletion test/test_attachment.rb
Expand Up @@ -137,7 +137,7 @@ class AttachmentTest < Test::Unit::TestCase
end end


should "remove strange letters and replace with underscore (_)" do should "remove strange letters and replace with underscore (_)" do
assert_equal "sheep_say_b__.png", @dummy.avatar.original_filename assert_equal "sheep_say_b_.png", @dummy.avatar.original_filename
end end


end end
Expand Down

0 comments on commit 311732b

Please sign in to comment.