From e3845ba0f64b3f29718abc89e769545fda87f45b Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Mon, 23 Feb 2009 20:07:43 -0600 Subject: [PATCH] Fix order of replacement in String#unescapeHTML [#544 state:resolved] (SWeini, kangax) --- CHANGELOG | 2 ++ src/lang/string.js | 2 +- test/unit/string_test.js | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c4a3071..3f84b1c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Fix order of replacement in String#unescapeHTML [#544 state:resolved] (SWeini, kangax) + * Fix issue where a Selector query rooted on a node that had not been attached to the document failed in IE. [#464 state:resolved] (jddalton, kangax, Douglas Fraser, Andrew Dupont) * Fix Selector to match elements with attributes containing hyphens. [#285 state:resolved] (leiyou, jddalton, kangax) diff --git a/src/lang/string.js b/src/lang/string.js index 5530ebb..47f4ba6 100644 --- a/src/lang/string.js +++ b/src/lang/string.js @@ -431,7 +431,7 @@ if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.proto return this.replace(/&/g,'&').replace(//g,'>'); }, unescapeHTML: function() { - return this.stripTags().replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); + return this.stripTags().replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&'); } }); diff --git a/test/unit/string_test.js b/test/unit/string_test.js index 3590579..a0b016c 100644 --- a/test/unit/string_test.js +++ b/test/unit/string_test.js @@ -255,6 +255,8 @@ new Test.Unit.Runner({ this.assertEqual('1\n2', '1\n2'.unescapeHTML()); this.assertEqual('Pride & Prejudice', '

Pride & Prejudice

'.unescapeHTML()); + this.assertIdentical('<', '&lt;'.unescapeHTML()); + this.benchmark(function() { largeTextEscaped.unescapeHTML() }, 1000); },