Repository navigation
fix: the text of a message's HTML is made by one scanner, not regular expressions - #60
Merged
Merged
Conversation
… expressions Three helpers made text of HTML with regular expressions: the Worker's text for a model, a tool and a quoted reply, the app's text part of a draft that is sent, and the app's decoding of character references. They missed an end tag written with a space, a line break or capitals, and decoded `&lt;` twice. Each result was text: escaped before it became HTML, put into a text node, given to a model, or not used by the server while the message has HTML. So none could inject markup, but the text was wrong, and code scanning flagged all three. All of them now use shared/html-text.ts, which already scans markup once and never keeps script or style content: `oneLineTextOf` for one line, `plainTextOf` with line breaks, each decoding a reference once. test/unit/html-text.test.ts gives each of the four makers the forms the expressions missed and a reference written twice, and quotes a message whose script is written with a space. Six of its tests fail with the old helpers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
…a test - scripts/pins.ts encodes every slash of a package name, not the first; a scoped name has one, so nothing changes today. - scripts/dev-setup.ts creates .dev.vars only when it is not there (`wx`), instead of asking first and writing after. - scripts/e2e-server.ts reads the built Worker's variables without asking first whether the file is there. - test/unit/content-policy.test.ts finds the document's scripts with any case and with a space before the end of the closing tag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
Contributor
Author
|
audit: one thing to correct, then pass Read: both commits line by line, and every caller of the three changed functions to where its value ends up. Tests and the two analyses are green; the code scanning gate is not.
What I checked and found to hold:
Not done by the auditor: the suites were not run a second time locally; CI ran them. |
…g in it Code scanning still flagged the pattern of the previous commit: an end tag such as `</script bar>` closes a script in a browser too. The end tag is now matched as the start tag is, by its name and up to `>`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
Contributor
Author
|
audit: pass The end tag of the test's pattern is corrected in |
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.
What and why
The first run of code scanning on this repository raised twenty alerts. Each was followed to where its value ends up; none is a way in. This change corrects the nine that pointed at code worth correcting; the other eleven are dismissed on the alerts themselves, each with its reason.
Opened by the auditor from the builder's pushed branch and report; the code and tests are the builder's.
Corrected here
workers/lib/email-helpers.ts,app/components/EmailPanel.tsx,app/lib/utils.ts). All three now use the one scanner the project already owns (shared/html-text.ts): the content of a script or a style is never text, however its tags are written, and each character reference is decoded once. The old helper decoded twice, which was a correctness defect (&lt;became<), not an injection: every place that uses the text as HTML escapes it first, and the others put it in a text node, give it to a model, or send it as the text part of a message.scripts/pins.tsreplaces every/of a package name,scripts/dev-setup.tscreates.dev.varsonly if it is not there in one step,scripts/e2e-server.tsreads without asking first, and the script tag pattern oftest/unit/content-policy.test.tsmatches a closing tag with a space.Dismissed on the alert, with the reason there
scripts/checks/copies.ts --fixon the developer's own checkout. Won't fix.Regression tests
test/unit/html-text.test.ts, "the text Podbay makes of a stranger's HTML": for each of the callers, script and style content is never kept and no tag survives; each character reference is decoded once; a quoted reply shows what was written as text and holds no element of it.Runs (the builder's, one at a time, on this branch)
pnpm checkgreen (725 unit tests), Workers runtime 630 of 630, browser 86 of 86.Checklist
pnpm checkandpnpm test:workerdare green.git commit -s).🤖 Generated with Claude Code