]> git.alsa-project.org Git - alsa-ucm-conf.git/commit
ucm2: use locale-agnostic character classes in parsing regexes HEAD master
authorJaroslav Kysela <perex@perex.cz>
Mon, 14 Sep 2026 16:34:49 +0000 (18:34 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 14 Sep 2026 16:35:08 +0000 (18:35 +0200)
commit18d142f3bfc9f59cecb4e6d65013da8c8cdccb65
tree1b601ea0c0f446c861ed54f10cf85a6fad5d0832
parentba372ade3434dfc802f6332cad874b6957456adb
ucm2: use locale-agnostic character classes in parsing regexes

Several UCM configuration regexes parse CardComponents using POSIX
bracket *ranges* such as "[a-z0-9]", "[a-z0-9-]" and "[0-9a-f]".
Range expressions are locale sensitive: the set of characters covered
by "x-y" depends on the current collation order (LC_COLLATE), not on
code points.

Under the Turkish locale (tr_TR.UTF-8) the dotless/dotted 'i' handling
reorders the collation sequence, so "[a-z]" no longer matches every
lowercase ASCII letter.  As a result the "mic:...-dmic" component in
sof-soundwire.conf is truncated (e.g. to "dm"), ALSA then tries to open
a non-existent "dm.conf" and the whole UCM import for the SoundWire card
aborts, leaving the user with a dummy-only audio profile (no speaker,
no microphone).

Fix the whole tree by switching to POSIX character classes, which are
defined by character classification instead of collation order and thus
match the intended ASCII set regardless of the active locale:

  - sof-soundwire.conf: "[a-z0-9]" -> "[[:alnum:]]",
                        "[a-z0-9-]" -> "[[:alnum:]-]"
  - USB-Audio.conf:     "[0-9a-f]" -> "[[:xdigit:]]"

[[:xdigit:]] is used for the USB vendor/device IDs because it matches
exactly the hexadecimal digits (and, unlike [[:digit:]], stays
restricted to ASCII in glibc).  Pure digit ranges such as "[0-9]" are
left untouched: digits do not collation-reorder and the range already
matches only ASCII digits.

Fixes: https://github.com/alsa-project/alsa-ucm-conf/issues/824
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
ucm2/USB-Audio/USB-Audio.conf
ucm2/sof-soundwire/sof-soundwire.conf