Skip to content

Conversation

behrmann
Copy link
Contributor

This adds re.ASCII in places where we use backslash character classes (\d or \w), so that arbitrary unicode numbers and letters are not accepted, where we might not expect them.

Also the character classes accepted for variable names in read_env_files is widened to what shells allow, so that we can guarantee roundtripping files read with it.

By default Python regexes like strings are unicode meaning that they match
anything unicode consides, e.g. a number in the case of \d, which is more than
the usually expected [0-9]. Tighten this in the places where these classes are
used for better readability.

Also reorder the character classes for KERNEL_VERSION_PATTERN and the
systemd-stub version to be the same order for clarity and escape the dash in
the latter, since the need to escape a dash in a character range is position
dependent.
Currently we only read uppercase variables starting with a letter, but shell
variables only restriction is not starting with a number, so lowercase names
and names starting with an underscore are allowed.
@DaanDeMeyer DaanDeMeyer merged commit fd37a70 into systemd:main Sep 24, 2025
34 of 40 checks passed
@behrmann behrmann deleted the relocale branch September 24, 2025 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants