From: yangguo@chromium.org Date: Thu, 7 Aug 2014 07:45:33 +0000 (+0000) Subject: Only escape U+0022 in argument values of `String.prototype` HTML methods X-Git-Tag: upstream/4.7.83~7756 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ec32f346d9c7d1e3ce32e67b03ed61a53e927ac;p=platform%2Fupstream%2Fv8.git Only escape U+0022 in argument values of `String.prototype` HTML methods Contributed by Mathias Bynens . TEST=mjsunit/es6/string-html BUG=v8:2217 LOG=Y R=arv@chromium.org, yangguo@chromium.org Review URL: https://codereview.chromium.org/446973004 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22955 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/string.js b/src/string.js index 5cd1c0c..ae65264 100644 --- a/src/string.js +++ b/src/string.js @@ -829,10 +829,7 @@ function StringFromCharCode(code) { // ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1 function HtmlEscape(str) { - return TO_STRING_INLINE(str).replace(//g, ">") - .replace(/"/g, """) - .replace(/'/g, "'"); + return TO_STRING_INLINE(str).replace(/"/g, """); } diff --git a/test/mjsunit/es6/string-html.js b/test/mjsunit/es6/string-html.js index b109c1d..4f3feb5 100644 --- a/test/mjsunit/es6/string-html.js +++ b/test/mjsunit/es6/string-html.js @@ -6,7 +6,7 @@ // http://mathias.html5.org/tests/javascript/string/ assertEquals('_'.anchor('b'), '_'); -//assertEquals('<'.anchor('<'), '<'); // #2217 +assertEquals('<'.anchor('<'), '<'); assertEquals('_'.anchor(0x2A), '_'); assertEquals('_'.anchor('\x22'), '_'); assertEquals(String.prototype.anchor.call(0x2A, 0x2A), '42'); @@ -63,7 +63,7 @@ assertThrows(function() { assertEquals(String.prototype.fixed.length, 0); assertEquals('_'.fontcolor('b'), '_'); -//assertEquals('<'.fontcolor('<'), '<'); // #2217 +assertEquals('<'.fontcolor('<'), '<'); assertEquals('_'.fontcolor(0x2A), '_'); assertEquals('_'.fontcolor('\x22'), '_'); assertEquals(String.prototype.fontcolor.call(0x2A, 0x2A), @@ -77,7 +77,7 @@ assertThrows(function() { assertEquals(String.prototype.fontcolor.length, 1); assertEquals('_'.fontsize('b'), '_'); -//assertEquals('<'.fontsize('<'), '<'); // #2217 +assertEquals('<'.fontsize('<'), '<'); assertEquals('_'.fontsize(0x2A), '_'); assertEquals('_'.fontsize('\x22'), '_'); assertEquals(String.prototype.fontsize.call(0x2A, 0x2A), @@ -102,7 +102,7 @@ assertThrows(function() { assertEquals(String.prototype.italics.length, 0); assertEquals('_'.link('b'), '_'); -//assertEquals('<'.link('<'), '<'); // #2217 +assertEquals('<'.link('<'), '<'); assertEquals('_'.link(0x2A), '_'); assertEquals('_'.link('\x22'), '_'); assertEquals(String.prototype.link.call(0x2A, 0x2A), '42');