Skip to content

fix: sanitize the root element of svgs in the preview - #4221

Closed
AlexAndBear wants to merge 1 commit into
mainfrom
fix/svg-root-attributes
Closed

AlexAndBear wants to merge 1 commit into
mainfrom
fix/svg-root-attributes

Conversation

@AlexAndBear

Copy link
Copy Markdown
Member

Description

The preview sanitizes svgs via transformSource of vue-inline-svg, but the library takes the attributes of the root <svg> from the unsanitized source, so event handlers on the root element survived. This extends our existing patch of vue-inline-svg so the root attributes come from the sanitized element as well.

Upstream fix: shrpne/vue-inline-svg#71. Once that's released, we can bump the package and drop this part of the patch.

Related Issue

  • no issue

How Has This Been Tested?

  • test environment: browser tests (Playwright) against a local OpenCloud
  • test case 1: svg with an event handler on the root element: before, the handler ran; now the image renders and the handler is gone
  • test case 2: harmless svgs still render, zoom, rotate and switching between svgs in the preview work
  • test case 3: the patched file installed by pnpm install --frozen-lockfile is byte-identical to the tested one; preview unit tests pass

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

@AlexAndBear

Copy link
Copy Markdown
Member Author

Closing in favor of #4298, which renders preview SVGs as images, so this patch isn't needed anymore.

@AlexAndBear AlexAndBear closed this Nov 5, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenCloud Team Board Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants