Skip to content

gh-159229: Fix IDNA incremental encoder error offsets - #159233

Closed
wjc2821296948 wants to merge 5 commits into
python:mainfrom
wjc2821296948:fix-idna-incremental-offset-159229
Closed

wjc2821296948 wants to merge 5 commits into
python:mainfrom
wjc2821296948:fix-idna-incremental-offset-159229

Conversation

@wjc2821296948

@wjc2821296948 wjc2821296948 commented Oct 12, 2026 •

Copy link
Copy Markdown

The IDNA incremental encoder tracks the consumed offset using the Unicode label length, even though it appends the IDNA-encoded bytes. For non-ASCII labels this makes a later UnicodeEncodeError report offsets that are too small.

Track the actual encoded byte length instead, and add a regression test covering a non-ASCII label followed by an invalid overlong label.

AI assistance was used to inspect the existing code and draft this focused change. The patch was reviewed against the issue reproducer and existing codec behavior before submission.

Closes #159229

wjc2821296948 and others added 2 commits October 12, 2026 20:37
Co-Authored-By: chaogeshuodiannao <chaogeshuodiannao@users.noreply.github.com>
Co-Authored-By: chaogeshuodiannao <chaogeshuodiannao@users.noreply.github.com>
@python-cla-bot

python-cla-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Co-Authored-By: chaogeshuodiannao <chaogeshuodiannao@users.noreply.github.com>
wjc2821296948 and others added 2 commits October 12, 2026 21:01
Co-Authored-By: chaogeshuodiannao <chaogeshuodiannao@users.noreply.github.com>
Co-Authored-By: chaogeshuodiannao <chaogeshuodiannao@users.noreply.github.com>
@wjc2821296948

Copy link
Copy Markdown
Author

Closing this because I missed that the issue reporter had already said they wanted to work on the fix.

Sorry for the overlap. I'll leave this issue to the reporter so they can submit their implementation.

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.

IDNA incremental encoder reports wrong error offset when a non-ASCII label precedes the invalid one

1 participant