Skip to content

router: idna::domain_to_ascii folds regex escapes in a Tree hostname, inverting \D into \d #1377

Closed

Description

@FlorentinDUBOIS

Summary

add_tree_rule folds the whole hostname through idna::domain_to_ascii, including the regex source
of a Tree-position frontend. For an uppercase regex escape this inverts the character class:
\D becomes \d, \W becomes \w, \S becomes \s.

A frontend written /[^\D]/.example.com therefore routes the complement of what the operator wrote,
silently.

Measured

idna::domain_to_ascii("/[^\\D]/.example.com")  ->  "/[^\\d]/.example.com"
idna::domain_to_ascii("/\\D+/.example.com")    ->  "/\\d+/.example.com"

And the meanings are opposites: [^\D] matches '7' and not 'a'; [^\d] matches 'a' and not
'7'.

Impact

Silent and invisible from configuration: the frontend loads, sozu query frontends shows exactly what
the operator typed, and the rule matches the wrong set of hosts. Affects Tree position only —
Pre/Post keep the regex source verbatim.

Uppercase escapes are not exotic; \D, \W, \S and \B are ordinary regex vocabulary.

Suggested direction

Case-fold only the literal labels, not the regex segments — the same split
convert_regex_domain_rule already makes between literal labels and /…/ segments. Whether the
hostname should be IDN-normalised at all once it contains a regex segment is the design question; a
regex segment is not a domain label and arguably should not go through domain_to_ascii.

Provenance

Found while fixing #1349 (host-case normalization), where the same folding is the reason a Tree
frontend cannot carry case-significant regex syntax. Deliberately scoped out of that change and left
untouched; it wants its own red-then-green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions