Skip to content

Bound XML encoding sniffing to the declaration - #12967

Merged
annevk merged 1 commit into
mainfrom
codex/fix-xml-encoding-boundary
Sep 21, 2026
Merged

annevk merged 1 commit into
mainfrom
codex/fix-xml-encoding-boundary

Conversation

@domenic

@domenic domenic commented Sep 21, 2026

Copy link
Copy Markdown
Member

Stop looking for "encoding" at the first > byte when sniffing an XML declaration in text/html. This prevents text after the declaration from selecting the document's encoding, matching Chromium, Gecko, and WebKit.

Fixes #6939.

  • At least two implementers are interested (and none opposed): everyone already implements this
  • Tests are written and can be reviewed and commented upon at: existing coverage in xmldecl-2.html, specifically gt-between-xml-and-encoding.htm and gt-between-xml-and-encoding-trail.htm. Both cases and two valid-declaration controls pass in Chromium, Firefox, and WebKit.
  • Implementation bugs are filed: not needed
  • Corresponding HTML AAM & ARIA in HTML issues & PRs: N/A
  • MDN issue is filed: N/A
  • The top of this comment includes a clear commit message to use.

(See WHATWG Working Mode: Changes for more details.)

Stop looking for "encoding" at the first > byte when sniffing an XML declaration in text/html. This prevents text after the declaration from selecting the document's encoding, matching Chromium, Gecko, and WebKit.

Fixes #6939.

Co-Authored-By: codex <codex@openai.com>

@annevk annevk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch.

I wondered if encoding="blah > blah" was also problematic, but it seems that in such a case we will always return failure so that is fine.

@annevk
annevk merged commit 24434a0 into main Sep 21, 2026
2 checks passed
@annevk
annevk deleted the codex/fix-xml-encoding-boundary branch September 21, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Logic error in the "get an XML encoding" algorithm?

2 participants