Skip to content

fix: preserve XML input lengths and parse declaration attributes - #1039

Merged
andiwand merged 2 commits into
mainfrom
review/21-xml-input
Oct 5, 2026
Merged

andiwand merged 2 commits into
mainfrom
review/21-xml-input

Conversation

@andiwand

@andiwand andiwand commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

XML string parsing passes the buffer length to pugixml and stays UTF-8. Stream parsing uses the shared checked reader and detects UTF-16/32 without cutting at a zero byte, and file parsing rejects lengths that cannot fit the stream API.

Encoding detection reads declaration attributes rather than searching arbitrary text, so stylesheet instructions and attribute values cannot select the document encoding. Remove an unused parser wrapper and use size_t for text-token offsets.

Validation: 144 XML, flat ODF, and OOXML tests pass, including UTF-16 buffer/stream parsing, failed input streams, and misleading encoding text.

@andiwand
andiwand force-pushed the review/20-table-spans branch from 35d7498 to 52fc542 Compare October 5, 2026 06:12
Base automatically changed from review/20-table-spans to main October 5, 2026 06:14
andiwand and others added 2 commits October 5, 2026 08:36
…stream

load_buffer with encoding_auto reads a latin1 declaration. The flat ODF
passes TextFile::text(), which is already UTF-8 but keeps its
declaration, so a latin1 document decoded its text twice and read "ä" as
"ä". The string overload now states encoding_utf8, as load_string did,
and keeps the explicit length. The stream overload reads raw bytes, so
it keeps the detection.

Tests cover the string overload, a latin1 flat ODF document, and
whitespace before the `=` of a declaration attribute.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gb1fLafqqzehpqPuU6uBfn
@andiwand
andiwand force-pushed the review/21-xml-input branch from 058564a to 8421f8e Compare October 5, 2026 06:46
@andiwand
andiwand merged commit 3ebf60a into main Oct 5, 2026
23 checks passed
@andiwand
andiwand deleted the review/21-xml-input branch October 5, 2026 06:55
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