Skip to content

Decode HTML entities and normalize whitespace in extracted post metadata - #263

Draft
fboucher wants to merge 2 commits into
mainfrom
copilot/bug-fix-weird-character-title
Draft

fboucher wants to merge 2 commits into
mainfrom
copilot/bug-fix-weird-character-title

Conversation

@fboucher

@fboucher fboucher commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

POST /api/posts/extractPostDetails stored the raw <title> text and <meta> content attributes without decoding HTML entities. As a result, Don&#39;t was saved and displayed literally instead of as Don't. This affects every add path that goes through the endpoint: the + buttons on /posts and /feeds, the bookmarklet, and search suggestions.

Changes

  • Testable extraction
    • Moved the HTML-to-Post logic out of ExtractPostDetailsFromUrl into a new public PostEndpoints.BuildPostFromHtml(HtmlDocument, string url). The network fetch stays in ExtractPostDetailsFromUrl.
  • Text normalization
    • A new private NormalizeText is applied to Title, Author and Excerpt.
    • It calls WebUtility.HtmlDecode once, so double-encoded input like &amp;#39; becomes &#39;. It then collapses whitespace runs, including a decoded &nbsp;, to single spaces and trims.
    • The decoded text is never re-parsed as HTML, so <T> and List<string> survive.
    • A missing node still gives null. An empty content attribute still gives "".
  • Tests
    • New PostHtmlExtractionTests runs offline against HTML strings. It covers named, decimal and hex entities, whitespace collapsing, angle brackets, single decoding, and missing nodes.
// <title>Your Skills Don&#39;t Count If Agents Can&#39;t Find Them</title>
post.Title; // "Your Skills Don't Count If Agents Can't Find Them"

Out of scope

Posts already saved are not migrated. FeedParser and the UI are unchanged.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@fboucher fboucher changed the title [WIP] Fix weird characters in post title Decode HTML entities and normalize whitespace in extracted post metadata Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

Weird character in title

2 participants