Skip to content

Commit

Permalink
ICU-21408 Prohibit alpha4 as language inside tlang.
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang committed Nov 24, 2020
1 parent 275d59a commit 0ab995e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion icu4c/source/common/uloc_tag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,13 @@ _isTransformedExtensionSubtag(int32_t& state, const char* s, int32_t len)
const int32_t kGotTKey = -1; // Got tkey, wait for tvalue. ERROR if stop here.
const int32_t kGotTValue = 6; // Got tvalue, wait for tkey, tvalue or end


if (len < 0) {
len = (int32_t)uprv_strlen(s);
}
switch (state) {
case kStart:
if (ultag_isLanguageSubtag(s, len)) {
if (ultag_isLanguageSubtag(s, len) && len != 4) {
state = kGotLanguage;
return TRUE;
}
Expand Down
4 changes: 3 additions & 1 deletion icu4c/source/test/intltest/localebuildertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ void LocaleBuilderTest::TestSetExtensionValidateTIllFormed() {
"9-",
"-9",
"-z",
// "Latn", // Per 2019-01-23 ICUTC, still accept 4alpha. See ICU-20321
"Latn",
"Latn-",
"en-",
"nob-",
Expand All @@ -1400,6 +1400,8 @@ void LocaleBuilderTest::TestSetExtensionValidateTIllFormed() {
"gab-Thai-TH-0bde-z9-abcde123-a1-",
"gab-Thai-TH-0bde-z9-abcde123-a1-a",
"gab-Thai-TH-0bde-z9-abcde123-a1-ab",
// ICU-21408
"root",
};
for (const char* ill : illFormed) {
UErrorCode status = U_ZERO_ERROR;
Expand Down

0 comments on commit 0ab995e

Please sign in to comment.