Repository navigation
fix(feed): escape an Atom summary once - #18
Merged
Merged
Conversation
An entry's <summary> was the rendered body with its tags stripped and its entities kept, escaped again for XML, so "Tom & Jerry" reached a feed reader as "Tom & Jerry". The text is now decoded once (with the single-pass decoder the syntax highlighter used, moved to html.rs) before the feed escapes it, and the 280-character cut counts characters, not bytes. Behavioural-change: an Atom entry's <summary> carries the body's text escaped once, and a summary outside ASCII is cut at 280 characters rather than 280 bytes.
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.
Closes the task
docs/tasks/an-atom-summary-escapes-twice.md(markedstatus: donein this branch).What changed
strip_html_truncateinplates-render/src/page.rsnow drops tags, then decodes the body's entities once, then cuts.generate_atom_feedescapes that plain text once, so the task's repro (<p>Tom & Jerry <3</p>) gives<summary>Tom & Jerry <3</summary>, not&amp;/&lt;.unescapethatsyntax.rsalready used for code blocks. It moves tohtml.rsaspub(crate)so the feed can use it without thesyntax-highlightingfeature. Its behaviour and its tests insyntax.rsare unchanged.Why
The rendered body is HTML, so escaping its stripped text again double-escapes every
&,<and>the author wrote. A feed reader decodes once and shows the entity, not the character.Note
The decoder knows only the entities twig writes (
< > " ' ' &), as before. Other entities in a hand-written HTML body, such as , still come out escaped as text, the same as they did before this change.Verification
page.rs:an_atom_summary_is_escaped_once(the task's repro),strip_html_truncate_counts_charactersandstrip_html_truncate_cuts_between_entities_not_inside_them. All three failed onmainand pass here.ship ci: all 7 jobs passed (fmt, clippy, test, docs, wasm, alone, msrv).prov check: no findings.