Repository navigation
fix(web): decode link-title entities without parsing the title as markup - #6
Draft
agentsfleet-dev[bot] wants to merge 1 commit into
Draft
agentsfleet-dev[bot] wants to merge 1 commit into
agentsfleet-dev[bot] wants to merge 1 commit into
Conversation
The M224 title regression run failed at "Check link title decoding":
unescapeString("TypeScript <T> guide & examples") returned
"TypeScript guide & examples" because the saved title was parsed as HTML
markup, so the literal <T> was tokenised as an element and dropped by
documentElement.textContent.
A link title is rendered as React text, so "<" is escaped before parsing.
The parser then stays in text mode while character references such as
"&" and "<" are still decoded, and all three unchanged assertions
of the regression hold. The regression file is added unchanged from the
pinned fixture commit 95a173d.
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.
Fixes the failed step
Check link title decodingof the M224 title regression run.Evidence
M224 title regressiontest: reproduce link-title decoding regression for M224 development drill #3,event=workflow_dispatch, attempt 1, headdev@154a1b86a0f747a091c36c151ea744fbe87a2ef4, conclusionfailure.title-regression(https://github.com/agentsfleet/linkwarden/actions/runs/41281464925/job/124774076429); failing step 10Check link title decoding, 2026-11-01T06:37:06Z → 06:37:07Z, exit code 1.yarn test run apps/web/lib/client/unescapeString.test.ts→Tests 1 failed | 2 passed (3); the failing case ispreserves literal angle-bracket text in a saved link title.Root cause
apps/web/lib/client/unescapeString.tshanded the saved link title straight toDOMParser().parseFromString(input, "text/html"), so the title was parsed as HTML markup. InTypeScript <T> guide & examplesthe parser tokenises<T>as an unknown start tag anddocumentElement.textContent— which concatenates only text nodes — drops it, leavingTypeScript guide & examples. A link title is displayed as React text, so it must never be interpreted as markup; the two passing cases passed only because&,<and>are character references, which the parser decodes.The defect is present on
devat154a1b8(blobfe0807aa); this draft only repairs it.Fix
Escape
<before parsing, so the title is always treated as text while character references are still decoded:Resulting behaviour against the three unchanged assertions:
Research & developmentResearch & development(unchanged)TypeScript <T> guideTypeScript <T> guide(unchanged)TypeScript <T> guide & examplesTypeScript <T> guide & examples(wasTypeScript guide & examples)Edge cases checked by inspection: empty input → empty output, non-ASCII text is preserved, a literal
</textarea>cannot break out because<is escaped, and&lt;still decodes exactly one level, as before.Files changed
apps/web/lib/client/unescapeString.ts— the fix above.apps/web/lib/client/unescapeString.test.ts— the regression of the failing run, added unchanged (blobff0b47366c02cbf165321919c5cb5b2980836c74, identical to the blob in the pinned fixture commit95a173dfb71746d8e5ed01b420815668e34806f3; the file is absent fromdev, which theapps/web/lib/clientlisting at154a1b8confirms).No workflow file is modified, no regression is weakened, skipped or removed.
Validation
The
M224 title regressionworkflow runs on this pull request and checks out the exact pull-request head, restores the pinned regression fixture and runsyarn test run apps/web/lib/client/unescapeString.test.ts. The same three assertions failed at the base head154a1b8(run 41281464925); the result of that workflow at this draft head is reported once it has run.