From 10413290872c1ef55c4c5cee0cc031117a5ae4fe Mon Sep 17 00:00:00 2001 From: Thomas Dvornik <amphro@gmail.com> Date: Mon, 18 Jul 2011 09:59:43 -0700 Subject: [PATCH] Let the browser take care of escaping HTML characters --- lib/codemirror.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/codemirror.js b/lib/codemirror.js index eb188e645..7fbd61d95 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; -- GitLab