From 6545911f30eb3fe895ab3480c61f3946f34ea262 Mon Sep 17 00:00:00 2001 From: Jungshik Shin Date: Thu, 4 May 2017 14:56:03 -0700 Subject: [PATCH] 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 Commit-Queue: Jungshik Shin Cr-Commit-Position: refs/heads/master@{#45115} --- src/runtime/runtime-intl.cc | 5 ++++- test/intl/general/case-mapping.js | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/runtime/runtime-intl.cc b/src/runtime/runtime-intl.cc index 18e635c4f7..2868ae5980 100644 --- a/src/runtime/runtime-intl.cc +++ b/src/runtime/runtime-intl.cc @@ -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; diff --git a/test/intl/general/case-mapping.js b/test/intl/general/case-mapping.js index feb0ff54f6..0028c4150f 100644 --- a/test/intl/general/case-mapping.js +++ b/test/intl/general/case-mapping.js @@ -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"));