fix(trending): decode HTML entities in scraped repo descriptions#408
Open
nankingjing wants to merge 3 commits into
Open
fix(trending): decode HTML entities in scraped repo descriptions#408nankingjing wants to merge 3 commits into
nankingjing wants to merge 3 commits into
Conversation
github.com/trending descriptions are HTML-escaped; the parser strips tags but left entities like &, &gsscsd#39;, < intact, so they showed up raw in the generated briefings. Decode named/decimal/hex entities after tag stripping. Search API results are already plain text and unaffected.
Author
|
Reviewed — decodeHtmlEntities handles named/decimal/hex entities in one pass, applied to both description and language fields. Ready for review. |
Author
|
Re-reviewed and added a guard for out-of-range numeric entities (e.g. |
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.
Problem
fetchGitHubTrending()insrc/trending.tsscrapes repo descriptions andlanguages from the
github.com/trendingHTML. It strips tags with.replace(/<[^>]+>/g, "")but never decodes HTML entities. GitHubHTML-escapes these fields, so entities such as
&,',<,>,"survive intoTrendingRepo.description/.language,flow verbatim into
buildTrendingPrompt(), and end up rendered raw in thegenerated briefings.
This is reproducible against the live page today — one of the current
trending descriptions is:
which should read
... framework & software ....Fix
Add a small
decodeHtmlEntities()helper and apply it after tag strippingfor both
descriptionandlanguage. It resolves named, decimal (&#NN;)and hex (
&#xNN;) references in a single regex pass, so already-decodedtext and unknown entities pass through untouched (e.g.
&lt;correctlystays
<).searchReposcome from the GitHub Search JSON API (already plain text), sothat path is intentionally left unchanged.
Verification (executed, not just read)
real description containing
&.named/decimal/hex, double-escaped, unknown entity, empty) — all pass.
prettier@3 --checkwith the repo.prettierrc: clean.tsc --noEmitwith the repotsconfig.json(strict,noUncheckedIndexedAccess): exit 0.eslint9.39 +typescript-eslint8.63 with the repoeslint.config.js:exit 0.
Minimal diff, no unrelated reformatting.