diff --git a/ecmascript/intl/locale_helper.cpp b/ecmascript/intl/locale_helper.cpp index fed096cf2e5fcee58a876ecebdd11addecb8dc09..477af394e115130cd451bff66c5a8ff415fa65c1 100644 --- a/ecmascript/intl/locale_helper.cpp +++ b/ecmascript/intl/locale_helper.cpp @@ -258,7 +258,6 @@ bool LocaleHelper::IsStructurallyValidLanguageTag(const JSHandle &ta std::string tagCollection = ConvertToStdString(tag); std::vector containers; std::string substring; - std::set uniqueSubtags; size_t address = 1; for (auto it = tagCollection.begin(); it != tagCollection.end(); it++) { if (*it != '-' && it != tagCollection.end() - 1) { @@ -270,7 +269,8 @@ bool LocaleHelper::IsStructurallyValidLanguageTag(const JSHandle &ta containers.push_back(substring); if (IsVariantSubtag(substring)) { std::transform(substring.begin(), substring.end(), substring.begin(), AsciiAlphaToLower); - if (!uniqueSubtags.insert(substring).second) { + // Ignore the first tag when checking for duplicate subtags. + if (std::count(containers.begin(), containers.end(), substring) > 2) { return false; } }