Repository navigation
Fix trie routing implementation to use ordinal comparison - #70048
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
No concrete defects were identified, but required review evidence was unavailable and regression tests were not executed.
No open issues 🎉
What changed in this PR
This PR aligns trie routing with the dictionary fallback’s ordinal ignore-case behavior, addressing incorrect Unicode-to-ASCII matches reported in #70047.
Changes:
- Replaces invariant lowercasing with ordinal lowercasing when constructing trie keys.
- Adds Kelvin-sign regression cases covering different lengths and positions, exact matches, and ASCII sibling case-insensitive matches.
| File | Description |
|---|---|
src/Http/Routing/test/UnitTests/Matching/ILEmitTrieJumpTableTest.cs |
Adds regression tests ensuring Kelvin-sign endpoints do not match ASCII k or K. |
src/Http/Routing/src/Matching/ILEmitTrieFactory.cs |
Uses ordinal lowercasing for both trie key sizes. |
Review effort: Balanced
I doubt that such discrepancy was intentional.
It's also extremely unlikely for APIs existing today to be using non-ASCII characters like the Kelvin sign which are equatable to ASCII characters when compared with invariant comparison. This reduces much the impact of this being a breaking change. |
|
✅ No documentation PR was created. Confidence that documentation is needed: 5% No docs needed: internal bug fix making trie routing use ordinal comparison, consistent with the dictionary fallback. No signals found. Documentation surfaces considered
|
Today, the trie implementation constructs the key using
ToLowerInvariant. This can cause specific unicode characters to get transformed to a lowercase ASCII character. After that, a received request using that ASCII lowercase character is going to incorrectly match which diverges from the behavior of the fallback dictionary (seeDictionaryJumpTable).This PR ensures we have consistent behavior in routing.
Fixes #70047