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:
parent
0a9bf389ef
commit
66f026aa78
@ -227,6 +227,13 @@ class Issue < ActiveRecord::Base
|
|||||||
@custom_field_values = nil
|
@custom_field_values = nil
|
||||||
result
|
result
|
||||||
end
|
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
|
# Overrides attributes= so that tracker_id gets assigned first
|
||||||
def attributes_with_tracker_first=(new_attributes, *args)
|
def attributes_with_tracker_first=(new_attributes, *args)
|
||||||
|
@ -738,7 +738,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
IssueCustomField.delete_all
|
IssueCustomField.delete_all
|
||||||
Issue.update_all("description = NULL", "id=1")
|
Issue.update_all("description = NULL", "id=1")
|
||||||
|
|
||||||
i = Issue.first
|
i = Issue.find(1)
|
||||||
i.init_journal(User.find(2))
|
i.init_journal(User.find(2))
|
||||||
i.subject = "blank description"
|
i.subject = "blank description"
|
||||||
i.description = "\r\n"
|
i.description = "\r\n"
|
||||||
@ -749,6 +749,11 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
end
|
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
|
def test_saving_twice_should_not_duplicate_journal_details
|
||||||
i = Issue.find(:first)
|
i = Issue.find(:first)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user