Repository navigation
fix(core): look publish refuses a logo browsers can't render - #703
Merged
Merged
Conversation
Owner
Author
|
Sol review: one finding dismissed, with reason Round 1, low: "Inputs with no root element (a truncated Dismissed. This is All other findings across the three rounds are fixed in this PR; the description lists them. |
The look checks read logo.svg with parse5's forgiving HTML parser, but every consumer shows the logo as an image, which browsers parse as strict, namespace-aware XML. An inline <svg> copied from a page passed the checks and then showed as a broken image in the specimen and in every patch. checkLogo now parses logo.svg with saxes (xmlns on) and walks that parse. A logo that isn't well-formed or namespace-valid is refused with its position, saxes' problem and the general fix, including XMLSerializer for an inline <svg>. A DOCTYPE, an XML 1.1 declaration and a namespace with spaces around it (saxes trims it, browsers don't) are refused, and the root must be svg in the SVG namespace. Every existing logo check keeps its message; attribute names still match case-insensitively, xlink:href counts as a reference, namespace declarations don't, and <style> CDATA goes to the CSS reference check. The XML parse replaces the bounded HTML parse from #678 for the logo. saxes has no repair or recursion, but resolves each element's namespace by searching the open elements, pairs each namespace with every prefixed attribute's name, and builds an Error per problem. So a logo nests at most 64 elements deep, a namespace is at most 256 characters, problems are recorded without Errors, and a logo past the look's size limit is refused for its size without being parsed. Closes #597 Co-Authored-By: Claude Opus 5.5 <[email protected]>
allisonmahmood
force-pushed
the
fix/597-logo-strict-xml
branch
from
October 15, 2026 22:02
b142c35 to
6a84ca2
Compare
allisonmahmood
added a commit
that referenced
this pull request
Oct 16, 2026
…u when they fail (#720) Release 13's What's new entry, written from `c9b8fc4`, ahead of deploying it. `patchy` and `CURRENT_RELEASE` move to `0.13.0`, so CLIs and patch repos installed before this deploy are told to upgrade. | Change | PRs | | --- | --- | | New: Home puts the patches you use first | #713, #716, #719 | | New: Every patch in one list | #715 | | Improved: Each patch's page leads with Open | #717 | | New: See when your tools are failing | #718 | | Fixed: Everyone has a name | #687 | | Improved: Your company's look is easier to get right | #697, #696, #703, #688 | | Improved: Forms follow your look's error states | #691, #692 | | Improved: Clearer answers when a publish goes wrong | #686, #685, #689 | | Fixed: Your agent's Patchy commands are steadier | #695, #704, #680, #681 | | Behind the scenes: stricter checks on static pages and tools' database requests; malformed requests are logged | #682, #693, #683 | | Behind the scenes: usage numbers count every publish, sharing change and restore | #698, #699, #700, #690 | | Test and tooling only, no line | #705, #702, #701, #694, #684, #607 | Made by Claude Opus 5.5 in Claude Code, running in T3 Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
look publishreadlogo.svgwith parse5's HTML parser, which recovers from mistakes. Every place a logo appears loads it as an image, and browsers parse images as strict, namespace-aware XML. So an inline<svg>copied from a company's site during onboarding (noxmlns, , an undeclaredxlink:prefix) passed every check, then showed as a broken image in the specimen and in every patch.Fix
checkLogoin@patchy/core/looknow parses the logo withsaxes, with namespaces on, and walks that parse. saxes is about 8 KB, ISC and pure JS, so the module stays browser-safe. parse5 stays in core for the HTML policy.&in<title>reportsunclosed tag: title). It also tells the agent to run an inline<svg>throughnew XMLSerializer().serializeToString(svg):logo.svg:1:56 is not well-formed XML (undefined entity); a logo is XML, not HTML, so quote every attribute, close every tag, declare prefixes such as xmlns:xlink, and write & as & and as  . For an inline <svg> copied from a page, serialize it with new XMLSerializer().serializeToString(svg) in a browser.<!DOCTYPE>is refused. The root must besvgin thehttp://www.w3.org/2000/svgnamespace, as resolved from the declarations. That covers a missing or wrongxmlns, and onlyxmlns:svgon an unprefixed root.xmlns, or a padded reservedxmlns:xml, is a broken image in Chromium and Firefox.version="1.0"is refused: Firefox shows any XML 1.1 logo as a broken image.xlink:hrefcounts as a reference,xmlns:*declarations don't, and<style>text, including CDATA, goes to the CSS reference check.With #678's bounds
#678 bounded the logo's parse5 parse (512 deep, 256 attributes, a repair budget) so that no upload could stall the server. The XML parse replaces that for the logo. saxes has no error repair and no recursion, but it has three costs of its own that I measured:
Errorwith a stack trace for every problem: about 0.5 s for 175k undefined entities in 512 KiB.So a logo nests at most 64 elements deep, and a namespace is at most 256 characters. Real logos nest a few elements deep, Chromium and Firefox render well past 5,000, and real namespaces are short URIs, so both are purely cost bounds. Problems are recorded without building an
Error, and a logo past the look's 512 KiB limit is refused for its size without being parsed. Measured warm againstmain's bounded parse5 on the same inputs:main<rect/>siblings<g/>siblings at depth 63 (the worst case left)#678's logo-bounds test is replaced by the 64/65 depth threshold. All of its inputs are malformed XML now.
Surfaces
docs/API.mdis re-rendered. No request or response shape changed.patchyREADME's look section describes the rule. There is no new command, flag or exit code, so ADR-0004 is unchanged. The global skill gains one sentence inlook-capture.md'slogo.svgsection.SKILL.mdis unchanged, soskills-lock.jsonis untouched.Tried by hand
In Chromium (Playwright), I took two inline logos as a browser reads them back through the DOM: GitHub's header mark from github.com, and the brief's typical site logo after parsing it as HTML. Each went into a look folder next to a fixture
look.cssandLOOK.md. Both read-backs render as broken images, andmain's checks accept both.Against this branch's dev environment (
pnpm dev up, team scenario), using the environment's packed CLI as Ada:patchy look previewon GitHub's mark printedlook publish would refuse this look: - logo.svg's <svg> is not in the SVG namespace; set xmlns="http://www.w3.org/2000/svg" on it.--jsoncarried the same line infailures, where it used to report none.patchy look publishrefused both read-backs with exit 1 andinvalid_look. The brief's logo gave thelogo.svg:1:56 … undefined entity …line above./api/look/publishwith curl, skipping the CLI's own check. The instance answered422 invalid_lookwith the same lines.new XMLSerializer().serializeToString(svg)on both logos in Chromium. Preview then reported no failures, and publish stored them as revisions 1 and 2.Linear's look, which reads like a wordmark (naturalWidth0). The specimen for the serialized logo rendered it (naturalWidth300).That run was on the commit before the rebase onto #678. On the rebased commit,
pnpm patchy look previewfrom source gives the same four results.I checked every refusal or acceptance added after review as an image in both Chromium and Firefox: padded
xmlnsandxmlns:xml, XML 1.1, namespace declarations, uppercase attributes, depth, and the brief's must-pass logos, including Patchy's own. WebKit couldn't launch on this machine.Review
GPT 6.1 Sol reviewed at xhigh over three rounds.
xmlns, XML 1.1 (widened after Firefox showed any 1.1 logo broken), namespace declarations read ashref/on*, attribute-name case, and README wording. The sixth is dismissed in a comment below.xmlns:xmland the long-namespace cost. Both are fixed.Left out
forceStatesgaps and logo<style>cascade rules stay accepted. Stored revisions aren't re-checked, and publish never repairs a logo.url(, e.g.data-x="fill:url(#g)", which makescheckLookthrow instead of refusing. This predates this PR onmainand needs its own fix.Closes #597
Made by Claude Opus 5.5 in Claude Code, running in T3 Code.