Normalize issue description EOLs do prevent false journal details (#8712).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6149 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-07-02 11:42:46 +00:00
parent 0a9bf389ef
commit 66f026aa78
2 changed files with 13 additions and 1 deletions

View File

@ -227,6 +227,13 @@ class Issue < ActiveRecord::Base
@custom_field_values = nil
result
end
def description=(arg)
if arg.is_a?(String)
arg = arg.gsub(/(\r\n|\n|\r)/, "\r\n")
end
write_attribute(:description, arg)
end
# Overrides attributes= so that tracker_id gets assigned first
def attributes_with_tracker_first=(new_attributes, *args)

View File

@ -738,7 +738,7 @@ class IssueTest < ActiveSupport::TestCase
IssueCustomField.delete_all
Issue.update_all("description = NULL", "id=1")
i = Issue.first
i = Issue.find(1)
i.init_journal(User.find(2))
i.subject = "blank description"
i.description = "\r\n"
@ -749,6 +749,11 @@ class IssueTest < ActiveSupport::TestCase
end
end
end
def test_description_eol_should_be_normalized
i = Issue.new(:description => "CR \r LF \n CRLF \r\n")
assert_equal "CR \r\n LF \r\n CRLF \r\n", i.description
end
def test_saving_twice_should_not_duplicate_journal_details
i = Issue.find(:first)