Skip to content

make-pdf blocks javascript: links written with tabs or entity letters, plus four small fixes (GST-3641) - #4848

Merged
capy-ai[bot] merged 7 commits into
mainfrom
make-pdf-sanitizer-gaps-and-small-fixes
Nov 26, 2026
Merged

capy-ai[bot] merged 7 commits into
mainfrom
make-pdf-sanitizer-gaps-and-small-fixes

Conversation

@garrytan

@garrytan garrytan commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

make-pdf now removes javascript: links in untrusted Markdown even when the scheme is split by a tab or line break or written with entity letters, and it fixes curly quotes at the start of a paragraph, SVG sizing, one learnings crash and one lost timeline event.
Why: these spellings still produced live links in the HTML make-pdf prints, and the other four bugs were verified on main by an independent check.
Nothing for readers to do; ordinary Markdown prints the same apart from opening quotes, which now curl the right way.

What changed
  • make-pdf sanitizer. Each URL attribute value (href, src, action, formaction, xlink:href) is decoded the way the browser decodes it, with tabs and line breaks removed. If it still starts with javascript:, a # goes in front, which makes the whole value a harmless fragment. The existing rules are unchanged, so this only adds catches. A click handler whose quoted value contains > is now removed with its value when it starts an attribute of its tag; inside another attribute's value only its name goes, as before. A numeric reference such as Ϋ that only starts like a colon no longer rewrites an ordinary link.
  • make-pdf typography. A quote right after a block tag (paragraph, heading, list item, table cell) opens. Inline tags such as <em> are read through, and images, code and unknown tags count as a word, so --flag and the quotes after a placeholder stay as they were.
  • SVG size. stroke-width and data-height are no longer read as the width or height, so a wide diagram moves to a sideways page again.
  • Learnings. A row whose files is a string or whose ts is a number no longer breaks every later search; the log stores a single path as a list; another project's learning never replaces this project's own.
  • Timeline. Every event is stored as one line, and a numeric ts no longer stops gstack-timeline-read.
Why

make-pdf prints Markdown that often comes from somewhere else, and its print browser runs page scripts, so a javascript: link that survives the sanitizer is live. The other four fixes are bugs an independent check reproduced on main. They caused wrong quote direction in most documents that open with a quote, left wide diagrams on upright pages, let one bad learnings row silence every later search, and skipped pretty-printed timeline events without a word.

Blast radius

make-pdf/src/render.ts, make-pdf/src/smartypants.ts, make-pdf/src/image-size.ts, bin/gstack-learnings-log, bin/gstack-learnings-search, bin/gstack-timeline-log, bin/gstack-timeline-read. No settings, defaults, dependencies, network, permissions or install changes. Rendering all 599 tracked Markdown files with main and with this branch changes only quote direction: 450 quote characters, every one from closing to opening at the start of a block, and nothing else.

Security notes
  • Attack replay over 8,090 generated cases (handlers, javascript: spellings with tabs, line breaks, entity letters, padding past 2,048 characters, attributes right after a closing quote), parsed with htmlparser2 with tabs and line breaks stripped from URLs the way browsers do: main leaves 1,530 live, this branch 0.
  • Still open, older than this PR: SVG animation attributes (<animate>/<set> with attributeName=href), data: and vbscript: schemes, and a remote href inside an unclosed <svg> after a > in an earlier quoted attribute.
Pre-Landing Review

Pre-Landing Review: 13 issues — 4 fixed, 0 asked, 1 deferred, 6 noted, 0 open. Four review rounds: two full rounds, then two read-only full reviews of later heads; the last one, at 3d90c13, came back with no blocking findings.

Deferred findings
  • Deferred: CRITICAL make-pdf/src/render.ts:368 The tab and entity javascript: catch also rewrites href=java&#9;script: text that sits inside another URL's path. Main already rewrites the plain href=javascript: spelling there the same way, so this is the existing fail-closed over-catch, not a new class.
Review notes
  • Informational: one crafted tag with thousands of quoted on…= values holding > is slow to sanitize (128 KB took about 16 s; main 3 ms), because each handler rescans its tag. Ordinary documents are unaffected.
  • Informational: a quote opening the text of details, summary or label still curls as closing, as on main.
  • Informational: this project's own learning now wins over another project's with the same key even when its confidence has decayed; that is the intended rule.
  • Informational: timeline events with their own ts are now re-serialized, so duplicate keys collapse to the last value.
Documentation

Status: current. No documentation edits were needed for this release.

Scope: 13 committed files (base fd81a04 to head eef1c54): make-pdf's untrusted-HTML sanitizer (javascript: links with tabs, line breaks or entity letters; click-handler values containing >; colon-like numeric entities), smartypants quote context at block starts, SVG width parsing, and fixes to gstack-learnings-search, gstack-learnings-log, gstack-timeline-log and gstack-timeline-read. No staged, unstaged or new files.

Documentation health:

  • changelog.d/make-pdf-sanitizer-gaps-and-small-fixes.md: current (describes every fix)
  • make-pdf/SKILL.md.tmpl: current (curly-quote and auto-landscape claims still hold)
  • learn/SKILL.md.tmpl: current (the latest-wins rule still holds within a project; own-beats-cross-project is not mentioned)
  • docs/troubleshooting.md: current
  • docs/designs/SELF_LEARNING_V0.md: historical, not changed

Coverage debt: None critical. All changes are bug fixes with no new public surface. The minor reference gap is that the learn skill does not say this project's own learnings win over other projects' learnings with the same key.

Diagram drift: none found.

Tests
  • bun test make-pdf/test/: 383 pass, 0 fail; learnings and timeline tests: 131 pass, 0 fail (final check at 3d90c13; the only later commit edits the release note). bun run typecheck clean.
  • Every fix has a test that fails on main fd81a04 and passes here.
  • CI on the final head eef1c54: every check green.
Agent notes

The four small fixes come from GEVA-584's blind verification (handoff GST-3627), rewritten on current main; credit to GEVA-584. Its learnings-log patch also refused non-string files; the verifier classed that as an improvement with no bug behind it, so it was left out. The three sanitizer additions are the rulings on #4762. Lane GSTA-832 for GStack Minder.

Approvals

Approved: yes (record r-ef437527616b). The full approval record stays private.
Plan: exempt: bug fix (R65)
Plan check: exempt bug fix

REVIEW_LOOP: passes=4 blocking_found=4 deferred=1 noted=6 fixed=4 scope=frozen ledgers_read=4 dispatches=8
Gate edits: none detected (9 listed, 1 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Ruling: the final-review blocker p3/red-team#1 was fixed in 3d90c13 under GStack Minder's ruling A (approval a-b8eecd8bad9d), then the final head got one read-only full review.

{
  "schema_version": 1,
  "pr": 4848,
  "head": "eef1c541fcf71dc393e9c501c35e9557ed8406f8",
  "version": "1.104.0.0",
  "base": "main",
  "gate": {
    "make-pdf": {
      "pass": 383,
      "fail": 0,
      "skip": 22
    },
    "learnings": {
      "pass": 131,
      "fail": 0,
      "skip": 0
    }
  },
  "calls": 31,
  "session_kind": "unattended",
  "run": "ship2",
  "head_tree": "cf3cfdac2ef72860c29a0cef35562d3006c3abb6",
  "product_patch_id": "7446963ff2f9db882d043f0e92cdbd7a59490952",
  "gstack_version": "1.104.0.0",
  "review_depth": {
    "depth": "full",
    "class": "code",
    "runtime_lines": 146,
    "rules": "33831f8248a814fd",
    "base": "4ec576aaa57ea76be375d4259e6dca7966abfa86",
    "registry": "4ec576aaa57ea76be375d4259e6dca7966abfa86",
    "gate_scan": {
      "tagged": 0,
      "head": "eef1c541fcf71dc393e9c501c35e9557ed8406f8"
    },
    "reasons": [
      "risk:security",
      "runtime=146"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel",
    "declared": [
      "security"
    ],
    "detected": []
  },
  "pregate": "requires-remote cleared @cf3cfdac2ef7 (8 checks, current for eef1c541fcf7)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/45850821074/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=cf3cfdac2ef7 tests=38491 skipped=67 runs=45850821074/1 profiles=ci-reuse/free-tests heads=eef1c541fcf7 base_moved=4ec576aaa57e verified=2026-11-26T15:42:17.491Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": [],
    "related": []
  },
  "docs": {
    "status": "current",
    "scope": "README.md, docs/, make-pdf/ (SKILL.md.tmpl and sources), learn/SKILL.md.tmpl"
  },
  "review_loop": {
    "passes": 4,
    "blocking_found": 4,
    "deferred": 1,
    "noted": 6,
    "fixed": 4,
    "scope": "frozen",
    "rounds": 4,
    "ledgers_read": 4,
    "dispatches": {
      "specialist": 4,
      "red-team": 4
    }
  },
  "gate_dispositions": []
}

garrytan and others added 6 commits November 26, 2026 14:36
…n answer; multi-line timeline events stay readable

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… and wide SVGs are measured by width, not stroke-width

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…entity letters

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/red-team#1 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p2/outside-voice#1 reader=outside-voice
Review-Finding: p2/outside-voice#3 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… checked too

Review-Finding: p3/red-team#1 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit f5b42d6 into main Nov 26, 2026
51 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