Skip to content

Commit

Permalink
Fixed a nil reference error in sanitize_filename
Browse files Browse the repository at this point in the history
  • Loading branch information
nbibler committed May 16, 2008
1 parent 6b7bc91 commit 61ad36f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/technoweenie/attachment_fu.rb
Expand Up @@ -371,6 +371,7 @@ def random_tempfile_filename
end

def sanitize_filename(filename)
return unless filename
returning filename.strip do |name|
# NOTE: File.basename doesn't work right with Windows paths on Unix
# get only the filename, not the whole path
Expand Down
3 changes: 3 additions & 0 deletions test/basic_test.rb
Expand Up @@ -42,6 +42,9 @@ def test_should_sanitize_filenames

@attachment.filename = 'f o!O-.bar'
assert_equal 'f_o_O-.bar', @attachment.filename

@attachment.filename = nil
assert_nil @attachment.filename
end

def test_should_convert_thumbnail_name
Expand Down

0 comments on commit 61ad36f

Please sign in to comment.