Handle private / grandfathered tags gracefully for case-conversion

Bug=v8:6083
Test=intl/general/case-mapping.js

Change-Id: I254c54520262298d6843948654d1dc4583b0c245
Reviewed-on: https://chromium-review.googlesource.com/496886
Reviewed-by: Adam Klein <adamk@chromium.org>
Commit-Queue: Jungshik Shin <jshin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45115}
This commit is contained in:
Jungshik Shin 2017-05-04 14:56:03 -07:00 committed by Commit Bot
parent 2bb21e169a
commit 6545911f30
2 changed files with 6 additions and 1 deletions

View File

@ -785,7 +785,10 @@ RUNTIME_FUNCTION(Runtime_StringLocaleConvertCase) {
s = String::Flatten(s);
// All the languages requiring special-handling have two-letter codes.
if (V8_UNLIKELY(lang_arg->length() > 2))
// Note that we have to check for '!= 2' here because private-use language
// tags (x-foo) or grandfathered irregular tags (e.g. i-enochian) would have
// only 'x' or 'i' when they get here.
if (V8_UNLIKELY(lang_arg->length() != 2))
return ConvertCase(s, is_upper, isolate);
char c1, c2;

View File

@ -128,6 +128,8 @@ assertEquals("abci\u0307", "aBcI\u0307".toLowerCase());
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("fil"));
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("zh-Hant-TW"));
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("i-klingon"));
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("i-enochian"));
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("x-foobar"));
// Up to 8 chars are allowed for the primary language tag in BCP 47.
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("longlang"));