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

Side by Side Diff: src/string.js

Issue 1237873003: [es6] Fix String.prototype.normalize to properly validate argument (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « src/i18n.js ('k') | test/mjsunit/string-normalize.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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 // Imports 10 // Imports
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 186
187 // ECMA-262 v6, section 21.1.3.12 187 // ECMA-262 v6, section 21.1.3.12
188 // 188 //
189 // For now we do nothing, as proper normalization requires big tables. 189 // For now we do nothing, as proper normalization requires big tables.
190 // If Intl is enabled, then i18n.js will override it and provide the the 190 // If Intl is enabled, then i18n.js will override it and provide the the
191 // proper functionality. 191 // proper functionality.
192 function StringNormalizeJS(form) { 192 function StringNormalizeJS(form) {
193 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); 193 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
194 194
195 var form = form ? TO_STRING_INLINE(form) : 'NFC'; 195 var form = IS_UNDEFINED(form) ? 'NFC' : TO_STRING_INLINE(form);
196 196
197 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; 197 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
198 var normalizationForm = 198 var normalizationForm =
199 %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf); 199 %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf);
200 if (normalizationForm === -1) { 200 if (normalizationForm === -1) {
201 throw MakeRangeError(kNormalizationForm, 201 throw MakeRangeError(kNormalizationForm,
202 %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin)); 202 %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin));
203 } 203 }
204 204
205 return %_ValueOf(this); 205 return %_ValueOf(this);
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 to.StringIndexOf = StringIndexOfJS; 1198 to.StringIndexOf = StringIndexOfJS;
1199 to.StringLastIndexOf = StringLastIndexOfJS; 1199 to.StringLastIndexOf = StringLastIndexOfJS;
1200 to.StringMatch = StringMatchJS; 1200 to.StringMatch = StringMatchJS;
1201 to.StringReplace = StringReplace; 1201 to.StringReplace = StringReplace;
1202 to.StringSplit = StringSplitJS; 1202 to.StringSplit = StringSplitJS;
1203 to.StringSubstr = StringSubstr; 1203 to.StringSubstr = StringSubstr;
1204 to.StringSubstring = StringSubstring; 1204 to.StringSubstring = StringSubstring;
1205 }); 1205 });
1206 1206
1207 }) 1207 })
OLDNEW
« no previous file with comments | « src/i18n.js ('k') | test/mjsunit/string-normalize.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698