Skip to content

Commit

Permalink
Fix order of replacement in String#unescapeHTML [#544 state:resolved]…
Browse files Browse the repository at this point in the history
… (SWeini, kangax)
  • Loading branch information
savetheclocktower committed Feb 24, 2009
1 parent 432a942 commit e3845ba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions 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)
Expand Down
2 changes: 1 addition & 1 deletion src/lang/string.js
Expand Up @@ -431,7 +431,7 @@ if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.proto
return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
},
unescapeHTML: function() {
return this.stripTags().replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
return this.stripTags().replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');
}
});

Expand Down
2 changes: 2 additions & 0 deletions test/unit/string_test.js
Expand Up @@ -255,6 +255,8 @@ new Test.Unit.Runner({
this.assertEqual('1\n2', '1\n2'.unescapeHTML());
this.assertEqual('Pride & Prejudice', '<h1>Pride &amp; Prejudice</h1>'.unescapeHTML());

this.assertIdentical('&lt;', '&amp;lt;'.unescapeHTML());

this.benchmark(function() { largeTextEscaped.unescapeHTML() }, 1000);

},
Expand Down

0 comments on commit e3845ba

Please sign in to comment.