FIX: Don't diplay character reference in HTML diffs (#4204)

* FIX: Don't diplay character reference in HTML diffs

Before this change, HTML escaping was done before splitting text into
tokens, so token splitter saw literals like "'", and split them as
it was normal text into parts into ["&", "#", "39", ";"]. This caused
diff to display character references, as those tokens used separate
HTML tags to display their insertion/deletion status.

* Avoid making one element arrays while generating diffs
This commit is contained in:
Konrad Borowski
2016-05-09 08:44:21 +02:00
committed by Régis Hanol
parent 1883fa205c
commit 9d737d894d
2 changed files with 13 additions and 2 deletions
+1 -2
View File
@@ -261,8 +261,7 @@ class DiscourseDiff
end
def characters(string)
string = CGI::escapeHTML(string)
@tokens.concat string.scan(/(\W|\w+[ \t]*)/).flatten
@tokens.concat string.scan(/\W|\w+[ \t]*/).map { |x| CGI::escapeHTML(x) }
end
end