Skip to content

slides: a web link whose address contains a dollar sign works again - #489

Merged
nyblnet merged 4 commits into
mainfrom
slides-math-href
Sep 15, 2026
Merged

nyblnet merged 4 commits into
mainfrom
slides-math-href

Conversation

@nyblnet

@nyblnet nyblnet commented Sep 15, 2026

Copy link
Copy Markdown
Owner

A web link whose address contains a dollar sign works again.

The bug (on main since web links arrived in #465, independent of the maths engine): resolveMath ran its $…$ rule over the whole sanitized HTML, so <a href="https://x.example/$a$b"> had its two dollars paired as an inline formula and a <math> written into the attribute — the xmlns quote ended the href and the > closed the tag: a dead link plus stray markup. Not exploitable: the sanitizer had already run, so nothing an author chose became an attribute. An integrity bug.

The fix, minimal, on the existing Temml-based resolveMath: split the string on tags (/(<[^>]*>)/), transform only the text runs, rejoin. A $ inside any tag never pairs with anything; a pair split across a tag boundary does not pair either; a formula wholly inside <b>…</b> still renders; the fussy inline rule (no whitespace inside, no digit after) is unchanged.

Measured in Chrome on the built shell: see <a href="https://x.example/$a$b">the link</a> and $x^2$ after → the link keeps href="https://x.example/$a$b", is clickable (pointer-events on, 103 px wide), no stray markup in the text, and $x^2$ beside it renders as one <math>; on the sidebar thumbnail the href is intact too; a $b <b>c$ d</b> renders no <math>. Zero console errors.

Rig scripts/test-slides-math-href.ts — 12 checks: the source holds the split and the text-run function (a mutant that calls the rule on the whole HTML goes red), and the behaviour with the same split and regexes: $ inside href untouched and the link intact; a formula in text beside a link renders with the href whole; a pair across a tag boundary does not pair; a formula inside a tag renders; a $ in the href with a price in the link text; display maths before a tag; prose with prices; any attribute, not just href. Registered in CI after the fields rig; ci-registered 338/338; typecheck OK. CHANGELOG line under [Unreleased].

… formulas are matched in text runs only

resolveMath ran its $…$ rule over the whole sanitized HTML, so an href
carrying $a$b (#465) had a <math> written into the attribute: a dead
link and stray markup. Nothing an author chose became an attribute — the
sanitizer had already run — but the link was gone. The string is now split
on tags and only the text runs are transformed, so a dollar in a tag never
pairs, and a pair split across a tag boundary does not pair either.
Rig: scripts/test-slides-math-href.ts (12 checks), in CI.
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

Build size

main (44ed9a2) → slides-math-href (b4f274f)

app base PR change
bento/slides 683.1 KiB 683.2 KiB +0.1 KiB (+0.01%)
bento/spaces 273.0 KiB 273.0 KiB 0.0 KiB (0.00%)
bento/dash 424.5 KiB 424.5 KiB 0.0 KiB (0.00%)

Updated: 2026-09-15T22:42:45Z

@nyblnet
nyblnet merged commit c73ae87 into main Sep 15, 2026
2 checks passed
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