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

Side by Side Diff: src/i18n.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 | « no previous file | src/string.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 // ECMAScript 402 API implementation. 5 // ECMAScript 402 API implementation.
6 6
7 /** 7 /**
8 * Intl object is a single object that has some named properties, 8 * Intl object is a single object that has some named properties,
9 * all of which are constructors. 9 * all of which are constructors.
10 */ 10 */
(...skipping 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 ); 1982 );
1983 1983
1984 1984
1985 /** 1985 /**
1986 * Unicode normalization. This method is called with one argument that 1986 * Unicode normalization. This method is called with one argument that
1987 * specifies the normalization form. 1987 * specifies the normalization form.
1988 * If none is specified, "NFC" is assumed. 1988 * If none is specified, "NFC" is assumed.
1989 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw 1989 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw
1990 * a RangeError Exception. 1990 * a RangeError Exception.
1991 */ 1991 */
1992 OverrideFunction(GlobalString.prototype, 'normalize', function(that) { 1992 OverrideFunction(GlobalString.prototype, 'normalize', function(form) {
1993 if (%_IsConstructCall()) { 1993 if (%_IsConstructCall()) {
1994 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); 1994 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
1995 } 1995 }
1996 1996
1997 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); 1997 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
1998 1998
1999 var form = GlobalString(%_Arguments(0) || 'NFC'); 1999 form = IS_UNDEFINED(form) ? 'NFC' : form;
2000 2000
2001 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; 2001 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
2002 2002
2003 var normalizationForm = 2003 var normalizationForm =
2004 %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf); 2004 %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf);
2005 if (normalizationForm === -1) { 2005 if (normalizationForm === -1) {
2006 throw MakeRangeError(kNormalizationForm, 2006 throw MakeRangeError(kNormalizationForm,
2007 %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin)); 2007 %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin));
2008 } 2008 }
2009 2009
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 } 2099 }
2100 2100
2101 var locales = %_Arguments(0); 2101 var locales = %_Arguments(0);
2102 var options = %_Arguments(1); 2102 var options = %_Arguments(1);
2103 return toLocaleDateTime( 2103 return toLocaleDateTime(
2104 this, locales, options, 'time', 'time', 'dateformattime'); 2104 this, locales, options, 'time', 'time', 'dateformattime');
2105 } 2105 }
2106 ); 2106 );
2107 2107
2108 }) 2108 })
OLDNEW
« no previous file with comments | « no previous file | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698