fix(anatomy): V1-2.2 owner arbitrations on SVG references and bytes

Refuse local references to ids a drawing does not define, scope canvas
ids per view, upload every drawing in one stored form checked by the
verdict and the preview, keep strict numeric rgb() colours, and commit
real Inkscape 1.4.3 exports with their generator.
This commit is contained in:
bchanot committed 2026-10-29 16:24:07 +01:00
1 parent 17d919971e
commit e823655f09
31 files changed
+1362 -110

No files matched your search

+25
View File
@@ -101,3 +101,28 @@ export function withTriggerNamesPerLanguage(tree: unknown, views: readonly ViewN
visit(copy)
return copy
}
/**
* Owner decision 2026-10-29 (V1-2.2): the canvas, inlined in the page, scopes the drawing's
* ids and the references to them to its view (`fv.<view>.<id>`). Applied to a frozen tree (a
* deep copy), written apart from the core's rewrite: every `id`, every `#id` href and every
* plain `url(#` (the only spelling of the product drawing). Mirrors
* `crates/core/tests/common/svg_tree.rs`.
*/
export function withIdsScopedPerView(tree: unknown, viewId: string): unknown {
const copy = structuredClone(tree)
const scope = `fv.${viewId}.`
const visit = (node: unknown): void => {
if (typeof node !== 'object' || node === null) return
const n = node as { attrs?: Record<string, string>; children?: unknown[] }
for (const [name, value] of Object.entries(n.attrs ?? {})) {
if (name === 'id') n.attrs![name] = `${scope}${value}`
else if ((name === 'href' || name === 'xlink:href') && value.startsWith('#')) {
n.attrs![name] = `#${scope}${value.slice(1)}`
} else n.attrs![name] = value.replaceAll('url(#', `url(#${scope}`)
}
n.children?.forEach(visit)
}
visit(copy)
return copy
}