Skip to content

fix(feed): escape an Atom summary once - #18

Merged
adammharris merged 1 commit into
mainfrom
agent/backlog-an-atom-summary-escapes-twice
Nov 9, 2026
Merged

adammharris merged 1 commit into
mainfrom
agent/backlog-an-atom-summary-escapes-twice

Conversation

@adammharris

Copy link
Copy Markdown
Member

Closes the task docs/tasks/an-atom-summary-escapes-twice.md (marked status: done in this branch).

What changed

  • strip_html_truncate in plates-render/src/page.rs now drops tags, then decodes the body's entities once, then cuts. generate_atom_feed escapes that plain text once, so the task's repro (<p>Tom &amp; Jerry &lt;3</p>) gives <summary>Tom &amp; Jerry &lt;3</summary>, not &amp;amp; / &amp;lt;.
  • The 280 limit counts characters, as its doc comment says, not bytes. A cut can no longer land inside an entity, because it happens after decoding.
  • The decoder is the single-pass unescape that syntax.rs already used for code blocks. It moves to html.rs as pub(crate) so the feed can use it without the syntax-highlighting feature. Its behaviour and its tests in syntax.rs are 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 (&lt; &gt; &quot; &#39; &apos; &amp;), as before. Other entities in a hand-written HTML body, such as &nbsp;, still come out escaped as text, the same as they did before this change.

Verification

  • New tests in page.rs: an_atom_summary_is_escaped_once (the task's repro), strip_html_truncate_counts_characters and strip_html_truncate_cuts_between_entities_not_inside_them. All three failed on main and pass here.
  • ship ci: all 7 jobs passed (fmt, clippy, test, docs, wasm, alone, msrv). prov check: no findings.

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 &amp; 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.
@adammharris
adammharris merged commit 8d9b56c into main Nov 9, 2026
8 checks passed
@adammharris
adammharris deleted the agent/backlog-an-atom-summary-escapes-twice branch November 9, 2026 22:46
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