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:
parent
2bb21e169a
commit
6545911f30
@ -785,7 +785,10 @@ RUNTIME_FUNCTION(Runtime_StringLocaleConvertCase) {
|
|||||||
s = String::Flatten(s);
|
s = String::Flatten(s);
|
||||||
|
|
||||||
// All the languages requiring special-handling have two-letter codes.
|
// 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);
|
return ConvertCase(s, is_upper, isolate);
|
||||||
|
|
||||||
char c1, c2;
|
char c1, c2;
|
||||||
|
@ -128,6 +128,8 @@ assertEquals("abci\u0307", "aBcI\u0307".toLowerCase());
|
|||||||
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("fil"));
|
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("fil"));
|
||||||
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("zh-Hant-TW"));
|
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("zh-Hant-TW"));
|
||||||
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("i-klingon"));
|
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.
|
// Up to 8 chars are allowed for the primary language tag in BCP 47.
|
||||||
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("longlang"));
|
assertEquals("abci\u0307", "aBcI\u0307".toLocaleLowerCase("longlang"));
|
||||||
|
Loading…
Reference in New Issue
Block a user