Repository navigation
feat(web): draw SVG images as PNGs so Read can show them - #379
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Board #134. Read cannot show an SVG, and many pages' charts are SVGs. Each saved SVG is now drawn as assets/NN.png beside assets/NN.svg, and the markdown link names the PNG (clipper/src/draw.ts): - one launch of the render path's Chromium per page, behind the same filtering proxy and flags, with a fresh profile; - each SVG drawn as an <img> from a data: URI on a blank document set with Page.setDocumentContent, at twice its natural size (its viewBox's when it names no width), its long edge at most 2,000 px, on white; - every SVG of a page within 20 s and the fetch's deadline. An SVG fetched by its own URL becomes image.svg plus image.png. Drawn as an image, an SVG runs no script and loads nothing it names except data: URIs. The new test aims ten channels at a host the boundary allows (@import, @font-face, a paint server, <image href>, xlink:href, <use>, <feImage>, <foreignObject>, a script's fetch and Image): drawing reaches none of them, and the same browser opening the SVG as a document reaches all ten. The reply names a drawn SVG's PNG with its source. An SVG not drawn (no Chromium, the time budget, an undecodable file) now says Read shows its source text, not the picture, where the reply used to invite a Read to see it. Pages without SVGs, and their meta.json, are byte-identical. Decision Log entry in the design. web 0.3.0. Sminos-Session: web-fetch-plugin#700c5e84 (doperpowers on macbook)
SSFSKIM
force-pushed
the
web-svg-raster
branch
from
October 25, 2026 21:18
d7385f6 to
5512616
Compare
… no longer ends the page's drawing Two review findings on the SVG drawing (board #134): - The size rule found the root with a regex on the raw source. Markup in a comment before the root was taken for it (an 800x200 chart drawn as a 20x20 thumbnail, and the page's link pointed at it), and a '>' inside a quoted root attribute hid the real viewBox. The root's width and viewBox are now read in the drawing's page, after the image decodes, by a DOMParser over the same bytes: Chromium's own XML parser, whose document runs no script and loads nothing (a probe of the ten trap channels made no request in 2 s; imported into the live page, the same root reached 7). The viewBox is used only with four finite numbers and a positive width and height; otherwise the natural size. - viewBox="0 0 1e999 100" passed the > 0 check as Infinity, the screenshot size became NaN, Chromium rejected it, and the outer catch marked every later SVG on the page not drawn. Now a measured size must be finite and positive, and a failure on one SVG marks only that one ("Chromium could not draw it (...)"); a spent time budget still kills the browser and ends the batch. Tests: real-Chromium cases for the comment, the quoted '>', a percentage width with a comma-separated viewBox, a width of its own, and the out-of-range viewBox followed by an ordinary SVG; stand-in-browser cases (fake-chrome.mjs now answers the drawing's commands) for a refused SVG followed by a drawn one, and for a time-out ending the batch. The pure viewBoxSize test goes with the function. The design's sizing wording follows. Sminos-Session: web-fetch-plugin#700c5e84 (doperpowers on macbook)
9 of 12 tasks
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.
Board #134.
Readcannot show an SVG, and many pages draw their charts as SVGs. Thewebclipper now draws each saved SVG as a PNG beside it and points the page's link at the PNG. The design was approved as proposed.web0.2.2 → 0.3.0 (rebased onto #380).What behaves differently
assets/NN.svggetsassets/NN.pngbeside it, and the markdown link names the PNG. The SVG stays, because its text (a chart's labels) is readable too.meta.json's image entry becomesfile: assets/NN.png, svg: assets/NN.svg.image.svgand drawn asimage.png, recorded aspngin the result.web/clipper/src/draw.ts):<img>from adata:URI on a blank document (Page.setDocumentContent), on white, and screenshotted;…/assets/11.png L85 "alt" (an SVG drawn as PNG; its source: …/assets/11.svg)…/assets/11.svg L85 "alt" (an SVG: Read shows its source text, not the picture; not drawn: <why>). The reply used to invite aReadto "see" an SVG.Image saved: …/image.png, drawn from the SVG …/image.svg. Read it to see it.Not drawn:Image saved: …/image.svg (an SVG: Read shows its source text, not the picture; not drawn: <why>).meta.jsonincluded. No new field appears unless there is an SVG.The image-mode claim and its proof
Drawn as an image, an SVG runs no script and loads nothing it names except
data:URIs, so drawing makes no request. The proxy is a second wall.test/draw.test.tsaims ten channels at the test server under a name the boundary allows:@import,@font-face, and a paint server;<image href>,xlink:href,<use>, and<feImage>;<foreignObject><img>;fetch, and a script'sImage.The drawing reaches none of them. As the control, the same browser, proxy and boundary open the same SVG as a document, and that reaches all ten.
Verification
cd web/clipper && npm testat3b5c8654: 145 pass, 0 skipped (Chromium present). New tests:bash web/tests/run.shat3b5c8654: all pass (145 clipper, the bundle check, 55 mod, 55 eval). ci-gate GREEN: https://github.com/SSFSKIM/doperpowers/actions/runs/40236089037cloud_platform.svgURL drew asimage.png. The driver also works with Google Chrome (--headless=new).Review
doperpowers:reviewer-mediumran two rounds.Round 1 found nothing blocking in security. Image mode held: 0 trap requests, with all 10 control channels live. A page without SVGs came out byte-identical,
meta.jsonincluded. It found two real sizing defects, fixed in3b5c8654:Infinity(0 0 1e999 100) made the screenshot size NaN, and the error ended the whole page's drawing;>, for the root's attributes.Now:
widthandviewBoxare read in the drawing page byDOMParserover the same bytes. Its document is inert: probes made no request, external entities and stylesheets included;Each new test fails on the previous code.
Round 2, on the fix commit, found no material findings.
Eval: the
imagetasks in configuration B, on this build20 runs on
solatxhigh(the approved spend), on the build before the rebase onto #380 (d7385f6e; #380 changes only extraction of documents with no<html>/<body>), set beside the last rounds' B numbers. Before is the final run for image-3 to image-5, and development round 3 for image-1 and image-2. Each cell is correct · median fetch calls · median sol tokens · median seconds · Reads of a.png/.svg.Sminos-Session: web-fetch-plugin#700c5e84 (doperpowers on macbook)