From fa15f212fa4bfad5ff4210bafee2913e66cf4758 Mon Sep 17 00:00:00 2001 From: Juriy Zaytsev Date: Sun, 22 Mar 2009 01:12:45 -0400 Subject: [PATCH] Fix `escapeHTML` in Chrome by using a more strict check. --- CHANGELOG | 2 ++ src/lang/string.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 736ad34..08cff6f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Make test for `escapeHTML`/`unescapeHTML` more strict. (Chrome 1.x escapes "<" and "&" with `innerHTML`, but not ">") (kangax) + * Remove another sniffing from one of DOM tests. Fixes last IE8 failure. (kangax) * `Element.extend` now takes care of IE8 bug when HTMLAppletElement and HTMLObjectElement objects do not inherit from `Element.prototype`. (kangax) diff --git a/src/lang/string.js b/src/lang/string.js index 90c2ea6..6d715c1 100644 --- a/src/lang/string.js +++ b/src/lang/string.js @@ -444,13 +444,13 @@ Object.extend(String.prototype.escapeHTML, { String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text); -if ('<\n'.escapeHTML() !== '<\n') { +if ('<\n>'.escapeHTML() !== '<\n>') { String.prototype.escapeHTML = function() { return this.replace(/&/g,'&').replace(//g,'>'); } } -if ('<\n'.unescapeHTML() !== '<\n') { +if ('<\n>'.unescapeHTML() !== '<\n>') { String.prototype.unescapeHTML = function() { return this.stripTags().replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&'); }