diff --git a/lib/codemirror.js b/lib/codemirror.js index eb188e6450437833df5b8c1219f4ac1bcce4199b..7fbd61d9542fc8d61d63d00977c2135b82b68b2b 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -2021,9 +2021,9 @@ var CodeMirror = (function() { function copyPos(x) {return {line: x.line, ch: x.ch};} function htmlEscape(str) { - return str.replace(/[<>&]/g, function(str) { - return str == "&" ? "&" : str == "<" ? "<" : ">"; - }); + var encodedHtmlElement = document.createElement("div"); + encodedHtmlElement.innerText = encodedHtmlElement.textContent = str; + return encodedHtmlElement.innerHTML; } CodeMirror.htmlEscape = htmlEscape;