Skip to content

Sniff XML encoding declarations - #30

Merged
domenic merged 1 commit into
mainfrom
codex/xml-encoding-sniffing
Sep 21, 2026
Merged

domenic merged 1 commit into
mainfrom
codex/xml-encoding-sniffing

Conversation

@domenic

@domenic domenic commented Sep 21, 2026

Copy link
Copy Markdown
Member

Implement XML declaration and UTF-16 signature sniffing in both modes, and fix meta declarations truncated at EOF or the prescan limit incorrectly supplying an encoding.

Implement HTML's UTF-16 byte signatures and XML-declaration fallback after meta scanning. Keep the meta prescan within 1024 bytes while allowing XML declarations to extend beyond that window, with the encoding label and closing quote required before the first `>`.

Extend `xml: true` with WebKit-compatible declaration and UTF-16 signature sniffing, retaining BOM and transport-layer precedence. Follow WebKit pending resolution of whatwg/html#12968. In both modes, normalize UTF-16 declaration labels to UTF-8 and preserve x-user-defined.

Ignore meta tags truncated by EOF or the prescan limit, which previously could supply an encoding despite their missing closing `>`.

Fixes #22.

Co-Authored-By: codex <codex@openai.com>
@domenic
domenic force-pushed the codex/xml-encoding-sniffing branch from 9eb8627 to 67f8869 Compare September 21, 2026 06:45
@domenic
domenic merged commit 3c79a06 into main Sep 21, 2026
5 checks passed
@domenic
domenic deleted the codex/xml-encoding-sniffing branch September 21, 2026 06:48
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