Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: src/string.js

Issue 446973004: Only escape U+0022 in argument values of `String.prototype` HTML methods (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/es6/string-html.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file relies on the fact that the following declaration has been made 5 // This file relies on the fact that the following declaration has been made
6 // in runtime.js: 6 // in runtime.js:
7 // var $String = global.String; 7 // var $String = global.String;
8 8
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 10
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 var code = %_Arguments(i); 822 var code = %_Arguments(i);
823 if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff; 823 if (!%_IsSmi(code)) code = ToNumber(code) & 0xffff;
824 %_TwoByteSeqStringSetChar(two_byte, j, code); 824 %_TwoByteSeqStringSetChar(two_byte, j, code);
825 } 825 }
826 return one_byte + two_byte; 826 return one_byte + two_byte;
827 } 827 }
828 828
829 829
830 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1 830 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2.1
831 function HtmlEscape(str) { 831 function HtmlEscape(str) {
832 return TO_STRING_INLINE(str).replace(/</g, "&lt;") 832 return TO_STRING_INLINE(str).replace(/"/g, "&quot;");
833 .replace(/>/g, "&gt;")
834 .replace(/"/g, "&quot;")
835 .replace(/'/g, "&#039;");
836 } 833 }
837 834
838 835
839 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2 836 // ES6 draft, revision 26 (2014-07-18), section B.2.3.2
840 function StringAnchor(name) { 837 function StringAnchor(name) {
841 CHECK_OBJECT_COERCIBLE(this, "String.prototype.anchor"); 838 CHECK_OBJECT_COERCIBLE(this, "String.prototype.anchor");
842 return "<a name=\"" + HtmlEscape(name) + "\">" + this + "</a>"; 839 return "<a name=\"" + HtmlEscape(name) + "\">" + this + "</a>";
843 } 840 }
844 841
845 842
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 "fixed", StringFixed, 975 "fixed", StringFixed,
979 "italics", StringItalics, 976 "italics", StringItalics,
980 "small", StringSmall, 977 "small", StringSmall,
981 "strike", StringStrike, 978 "strike", StringStrike,
982 "sub", StringSub, 979 "sub", StringSub,
983 "sup", StringSup 980 "sup", StringSup
984 )); 981 ));
985 } 982 }
986 983
987 SetUpString(); 984 SetUpString();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/es6/string-html.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698