Skip to content

fix(framework): normalize Unicode command routing - #167

Merged
iriswolf merged 2 commits into
mainfrom
fix/147-unicode-command-normalization
Jul 22, 2026
Merged

fix(framework): normalize Unicode command routing#167
iriswolf merged 2 commits into
mainfrom
fix/147-unicode-command-normalization

Conversation

@iriswolf

Copy link
Copy Markdown
Member

Summary

  • normalize exact command patterns and incoming command tokens to Unicode NFC
  • normalize command-template patterns and bodies while preserving raw Message.Text
  • keep CommandRegex and all text route kinds free from implicit normalization
  • document that string values bound by CommandTemplate use NFC
  • cover direct and generated registration with canonical-equivalence regression tests

Contract

Canonically equivalent sequences now match the same exact or template command. For example, composed ё (U+0451) matches decomposed е plus combining diaeresis (U+0435 U+0308).

This does not alias the distinct letters е and ё. Applications that accept both spellings still declare both routes explicitly.

The original Telegram message text remains unchanged in MessageContext. Regex routes preserve application-owned matching and capture semantics.

Touched hot paths

  • TelegramRouteDescriptor normalizes exact/template patterns once during route-table construction.
  • TelegramHandlerSelector normalizes only exact command tokens and command-template bodies immediately before matching.
  • Already normalized strings are returned unchanged, avoiding replacement-string allocation in the normal path.
  • Prefix extraction, bot-mention matching, regex routes, text routes, filter evaluation, and handler invocation are intentionally unchanged.

Validation

  • dotnet test .\TeleFlow.sln --no-restore --verbosity minimal — 849 passed
  • dotnet format style .\TeleFlow.sln --verify-no-changes --no-restore --verbosity minimal
  • .\eng\verify-strict-analyzers.ps1 -Configuration Release -NoRestore
  • git diff --check origin/main...HEAD

Documentation

Updated the English and Russian routing fundamentals/reference pages and the unreleased changelog.

Closes #147

@iriswolf
iriswolf merged commit a8c2085 into main Jul 22, 2026
16 checks passed
@iriswolf
iriswolf deleted the fix/147-unicode-command-normalization branch July 22, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate Unicode normalization in command routing

1 participant