[mono] Possible fragile code in /src/mono/browser/runtime/globalization-locale.ts #112573
Labels
arch-wasm
WebAssembly architecture
area-System.Globalization
in-pr
There is an active PR which will close this issue when it is merged
In the removal of HybridLocalization in PR #110567 the following code was introduced into globalization-locale.ts
Firstly, the Chinese language check should be a check of
startsWith(
the prefix"zh-"
, notinclude(
the more ambiguous"zh"
. This could lead to problems if someone was using the substring zh in any of the other parts of the locale string. To ensure this works with locales formatted with underscores, we need to move up thatlocale.replace("_", "-")
to the first line.Secondly, per RFC 5646 the script code should be upper-case initial letter and lower-case the rest, so the replacement constants should be
"Hans"
and"Hant"
respectively. Also, since those replacement patterns for those subparts are supposed to be targeting the script indicator, it would be much safer to include the '-' prefix.In short, this normalizeLocale function should probably be this:
The text was updated successfully, but these errors were encountered: