Repository navigation
Replace C0 control characters with U+FFFD when writing - #101
Merged
andy128k merged 1 commit intoNov 16, 2026
Merged
Conversation
XML 1.0 forbids C0 control characters other than tab, LF and CR, even as character references, but the writer emitted them raw, so a stray U+001E in a title produced a document that strict parsers such as xmllint reject. Replace them in the output stream, which covers text and attribute values alike. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
emschwartz
force-pushed
the
replace-control-chars
branch
from
November 11, 2026 16:27
cc15b5c to
188ef62
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #101 +/- ##
==========================================
+ Coverage 83.85% 84.27% +0.41%
==========================================
Files 14 14
Lines 1016 1030 +14
==========================================
+ Hits 852 868 +16
+ Misses 164 162 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
DCjanus
self-requested a review
November 12, 2026 06:43
andy128k
reviewed
Nov 16, 2026
Member
|
Nice. But why not to contribute this change to |
DCjanus
removed their request for review
November 16, 2026 03:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Writing a feed whose text contains a C0 control character produced a document that strict XML parsers reject.
Before (
xmllint --nooutfails with "PCDATA invalid Char value 30"):After (
xmllint --nooutpasses), the character is written as a raw U+FFFD:XML 1.0 forbids C0 controls other than tab, LF and CR everywhere, even as
, so they cannot be escaped. Seen in production on a reader that scraped U+001E and U+0008 into titles. The fix wraps the output ofFeed::write_with_configandEntry::write_with_configin a smallWriteadapter, so every text, attribute, element name and attribute name is covered.The characters are replaced with U+FFFD rather than dropped so the text on either side cannot join into a new token (
<scr\u{1}ipt>must not become<script>). C0 bytes never occur inside multi-byte UTF-8, so the swap keeps the output valid UTF-8. U+FFFE and U+FFFF are not handled.Tested with
write_replaces_control_characters(title, html summary, category term). It asserts the raw output has no forbidden byte, since the crate's own parser is lenient, then parses it back.cargo test --all-targetspasses with and without default features andcargo fmt --checkis clean.Test output before the fix
Authored by Claude (claude-sonnet-5-5, claude-opus-5-5)