Skip to content

gh-161090: Reject a leading delimiter in the punycode decoder - #161091

Merged
gpshead merged 1 commit into
python:mainfrom
gpshead:punycode-leading-delimiter
Nov 1, 2026
Merged

gpshead merged 1 commit into
python:mainfrom
gpshead:punycode-leading-delimiter

Conversation

@gpshead

@gpshead gpshead commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Only treat a - as the delimiter between the basic and extended parts if at least one basic code point precedes it, as RFC 3492 section 6.2 (and the reference decoder in its appendix C) requires. A leading - is now left in the extended part, where it hits the existing invalid-digit error, so b"-80a1acny" raises UnicodeDecodeError at offset 0 (or decodes to "" with errors="ignore"). This makes decoding stricter, so it is meant for main only; no encoder produces such input.

Fixes #161090

ANT-2026-0IEDOPPK

RFC 3492 section 6.2 only consumes the delimiter when at least one basic
code point precedes it.  A leading "-" is now an invalid digit.
@gpshead gpshead self-assigned this Nov 1, 2026
@gpshead
gpshead marked this pull request as ready for review November 1, 2026 18:24
@gpshead
gpshead merged commit ea784fa into python:main Nov 1, 2026
58 checks passed
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.

punycode codec accepts a delimiter with no basic code points before it

1 participant