Skip to content

FIX: validate UnicodeSubstitution output code points - #2559

Open
Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 2 commits into
microsoft:mainfrom
sylvesterkaczmarek:fix/unicode-substitution-codepoint-range
Open

FIX: validate UnicodeSubstitution output code points#2559
Sylvester Kaczmarek (sylvesterkaczmarek) wants to merge 2 commits into
microsoft:mainfrom
sylvesterkaczmarek:fix/unicode-substitution-codepoint-range

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Description

UnicodeSubstitutionConverter computes each encoded character with chr(start_value + ord(character)) without validating the resulting Unicode code point.

Invalid configuration values or a valid high start_value combined with an input character can therefore leak Python's low-level chr() arg not in range(0x110000) exception from conversion.

This change validates the configured starting value and checks each derived code point before conversion, raising a clear ValueError when the requested substitution would fall outside the Unicode range.

Tests

Adds regression coverage for invalid start values and for a valid start value whose offset would overflow for the input character.

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.

1 participant