summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-03-26 10:20:10 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-03-26 10:20:10 +0000
commit25eb92c0dc337b3a1167642433a3d6af73c1a68d (patch)
treea97eb7469659d2446be79de08587bc7e1e60bce4 /test
parent197ec295e036f3aaf574df3a804a29a88c48161d (diff)
downloadredmine-25eb92c0dc337b3a1167642433a3d6af73c1a68d.tar.gz
redmine-25eb92c0dc337b3a1167642433a3d6af73c1a68d.zip
Text in the "removed" part of a diff is double-escaped (#22115).
Patch by Felix Schäfer. git-svn-id: http://svn.redmine.org/redmine/trunk@15287 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/lib/redmine/helpers/diff_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/unit/lib/redmine/helpers/diff_test.rb b/test/unit/lib/redmine/helpers/diff_test.rb
index c6654ceac..be74a9071 100644
--- a/test/unit/lib/redmine/helpers/diff_test.rb
+++ b/test/unit/lib/redmine/helpers/diff_test.rb
@@ -22,4 +22,16 @@ class DiffTest < ActiveSupport::TestCase
diff = Redmine::Helpers::Diff.new("foo", "bar")
assert_not_nil diff
end
+
+ def test_dont_double_escape
+ # 3 cases to test in the before: first word, last word, everything inbetween
+ before = "<stuff> with html & special chars</danger>"
+ # all words in after are treated equal
+ after = "other stuff <script>alert('foo');</alert>"
+
+ computed_diff = Redmine::Helpers::Diff.new(before, after).to_html
+ expected_diff = '<span class="diff_in">&lt;stuff&gt; with html &amp; special chars&lt;/danger&gt;</span> <span class="diff_out">other stuff &lt;script&gt;alert(&#39;foo&#39;);&lt;/alert&gt;</span>'
+
+ assert_equal computed_diff, expected_diff
+ end
end