Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG file directive to disable SVGO #1782

Closed
hrumhurum opened this issue Sep 11, 2023 · 1 comment
Closed

SVG file directive to disable SVGO #1782

hrumhurum opened this issue Sep 11, 2023 · 1 comment

Comments

@hrumhurum
Copy link

Problem

svgo has several long standing bugs like #1077. At the same time, svgo project deeply penetrated content processing toolchains like Docusaurus and others. Unfortunately, those toolchains do not provide a straightforward way to configure the svgo instance they use. As the result, some .svg files cannot be used because they always get broken by svgo optimizations.

Proposed Solution

Provide a way to disable svgo with a directive inside an affected .svg file. This can be achieved by introducing a separate XML namespace, like so:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:svgo="https://github.com/svg/svgo" svgo:enabled="0">
</svg>

Alternatives

One alternative is to wait for a svgo bug to get fixed. Unfortunately, this may be a slow process without guarantees.

Another alternative is to programmatically configure the svgo instance inside a particular toolchain. Unfortunately, it is often impossible without hacks or patches, as not all toolchains provide a way to programmatically configure the tools they use.

@SethFalco
Copy link
Member

I don't think this is something that should be handled in SVGO.

There are two scenarios to consider:

  • Cloud hosts that use SVGO on server-side, users shouldn't have control over the pipeline.
  • Tooling that uses SVGO to circumvent XSS, like IPX (and thus Nuxt). If the SVG can bypass SVGO by adding the proposed attribute, that would undermine it.

A solution for problems above would be for SVGO to expose an option for whether this attribute was enabled or not, disabled by default. But as you've expressed, a lot of tooling isn't exposing SVGO's configuration, so you wouldn't be able to enable this anyway.

One alternative is to wait for a svgo bug to get fixed.

I'm working actively to address the backlog of issues and pull requests that've been piling up, and already have many bug fixes queued to be released in v3.0.3. As you've highlighted #1077, I can give this one a look next.

Meanwhile, what you've raised with tools not exposing the SVGO config is a real issue. I'll see if I can review Docusaurus afterward and introduce a way to expose SVGO.

@SethFalco SethFalco closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants