Skip to content

Harden handling of symbol SVG from outside the app - #1015

Merged
DutchSailor merged 2 commits into
mainfrom
fix/symbol-svg-sanitize
Nov 10, 2026
Merged

DutchSailor merged 2 commits into
mainfrom
fix/symbol-svg-sanitize

Conversation

@DutchSailor

Copy link
Copy Markdown
Collaborator

Stricter handling of symbol SVG that does not ship with the app, and quote escaping in two generated-markup paths.

What changes

  • New js/core/svg-veilig.js: SVG from outside the app (online library collections, imported and custom symbol groups, edited symbol types, catalogue previews, extension palette icons, the symbol type editor) goes through an allowlist of drawing elements and attributes with a strict XML parse. Anything outside the list is removed, and markup that does not parse cleanly is refused. Previously stored collections and groups are cleaned once at start-up.
  • The symbol palette shows symbols that do not ship with the app as <img> data URLs instead of inline markup.
  • Release-note markdown and the text-edit overlays escape " in generated attributes.

The bundled libraries (155 symbols) and all 512 SVGs of the online library pass through unchanged.

Verification

  • node --test js/core/svg-veilig.test.mjs (13 tests, including a corpus of malformed and unexpected inputs) and js/help/release-notes-markdown.test.mjs
  • scripts/test-symbol-library-online.mjs against a checkout of the library: 789 checks, 0 failures
  • node scripts/draai-unit-tests.mjs: 8072 tests, 0 fail
  • npx vite build, npm run build:hosted: exit 0

Not verified

  • No live GUI check of the palette thumbnails as images (size, alignment, dark theme), the symbol type editor and extension palette icons.

🤖 Generated with Claude Code

Replace the pattern check for symbol SVGs from outside the app with a
strict parser that keeps only known drawing elements and attributes and
writes the SVG back from the parsed tree (js/core/svg-veilig.js).

- online library collections, imported symbol groups and files, linework
  catalog previews and edited symbol types go through it on entry, and
  stored groups and symbol types are cleaned once at startup
- thumbnails of non-built-in symbols render as <img> data URLs instead of
  inline markup
- the symbol type editor and extension palette icons only receive cleaned
  markup without <style>
- shipped libraries pass through unchanged
Link URLs in release notes end up in a double-quoted href attribute, so
quotes are now escaped along with the other markup characters. The text
editor overlays escape quotes the same way.
@DutchSailor
DutchSailor merged commit e5992dc into main Nov 10, 2026
9 checks passed
@DutchSailor
DutchSailor deleted the fix/symbol-svg-sanitize branch November 10, 2026 07:57
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