GitLab steht wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit 98e05aa6 authored by jplang's avatar jplang

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

git-svn-id: https://svn.redmine.org/redmine/trunk@6149 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent a23f4455
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment