From: Adrian Vovk Date: Sun, 4 Feb 2024 17:18:08 +0000 (-0500) Subject: locale-util: Restrict valid locales X-Git-Tag: v256-rc1~873^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa485e8fc5adfbfce28af865c689376840562bab;p=thirdparty%2Fsystemd.git locale-util: Restrict valid locales This further restricts the charset of locales to better reflect what locales actually look like. This allows us to safely join locale names using the `:` character, for instance, which cannot appear in a locale name and is used by the `$LANGUAGE` env var --- diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c index 9e70c3f01fb..e6da5dbc631 100644 --- a/src/basic/locale-util.c +++ b/src/basic/locale-util.c @@ -260,7 +260,10 @@ bool locale_is_valid(const char *name) { if (!filename_is_valid(name)) return false; - if (!string_is_safe(name)) + /* Locales look like: ll_CC.ENC@variant, where ll and CC are alphabetic, ENC is alphanumeric with + * dashes, and variant seems to be alphabetic. + * See: https://www.gnu.org/software/gettext/manual/html_node/Locale-Names.html */ + if (!in_charset(name, ALPHANUMERICAL "_.-@")) return false; return true;