Skip to content

gh-161102: Fix idna incremental decoder after leading empty labels - #161103

Merged
gpshead merged 1 commit into
python:mainfrom
gpshead:idna-incremental-leading-dots
Nov 1, 2026
Merged

gpshead merged 1 commit into
python:mainfrom
gpshead:idna-incremental-leading-dots

Conversation

@gpshead

@gpshead gpshead commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Count the separating dot in IncrementalDecoder._buffer_decode() whenever a label has already been decoded (if result:, as Codec.encode() does), instead of whenever the byte count so far is non-zero, which is false after empty labels. Counting it before ToUnicode() also makes the UnicodeDecodeError position match the one-shot decoder. The encoder's identical if size: test is left alone because ToASCII() rejects empty labels.

Fixes #161102

ANT-2026-KFX1PUWZ

Count the separating dot for every label after the first, so dots after
leading empty labels are not decoded again by the next call.
@gpshead gpshead added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Nov 1, 2026
@gpshead gpshead self-assigned this Nov 1, 2026
@gpshead
gpshead marked this pull request as ready for review November 1, 2026 18:10
@gpshead
gpshead enabled auto-merge (squash) November 1, 2026 18:10
@gpshead
gpshead merged commit 2982d93 into python:main Nov 1, 2026
62 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Nov 1, 2026

Copy link
Copy Markdown

GH-161129 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Nov 1, 2026
@bedevere-app

bedevere-app Bot commented Nov 1, 2026

Copy link
Copy Markdown

GH-161130 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Nov 1, 2026
gpshead added a commit that referenced this pull request Nov 1, 2026
…bels (GH-161103) (#161129)

Count the separating dot for every label after the first, so dots after
leading empty labels are not decoded again by the next call.

ANT-2026-KFX1PUWZ

(cherry picked from commit 2982d93)
gpshead added a commit that referenced this pull request Nov 1, 2026
…bels (GH-161103) (#161130)

Count the separating dot for every label after the first, so dots after
leading empty labels are not decoded again by the next call.

ANT-2026-KFX1PUWZ

(cherry picked from commit 2982d93)
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 decoder decodes dots twice after leading empty labels

1 participant