Skip to content

Commit ef003ca

Browse files
committed
Wrong syntax for resizing inline images may throw a 500 error (#20278).
Fix by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@14473 e93f8b46-1217-0410-a6f0-8f06a7374b81
1 parent 279e4b7 commit ef003ca

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app/models/attachment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def self.update_attachments(attachments, params)
294294

295295
def self.latest_attach(attachments, filename)
296296
attachments.sort_by(&:created_on).reverse.detect do |att|
297-
att.filename.downcase == filename.downcase
297+
filename.casecmp(att.filename) == 0
298298
end
299299
end
300300

test/unit/attachment_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,13 @@ def test_latest_attach
327327
set_tmp_attachments_directory
328328
end
329329

330+
def test_latest_attach_should_not_error_with_string_with_invalid_encoding
331+
string = "width:50\xFE-Image.jpg".force_encoding('UTF-8')
332+
assert_equal false, string.valid_encoding?
333+
334+
Attachment.latest_attach(Attachment.limit(2).to_a, string)
335+
end
336+
330337
def test_thumbnailable_should_be_true_for_images
331338
assert_equal true, Attachment.new(:filename => 'test.jpg').thumbnailable?
332339
end

0 commit comments

Comments
 (0)