| ▲ | andybak 7 hours ago | ||||||||||||||||||||||||||||||||||
My first thought is "support a tiny subset of svg that probably still covers 90% of real-world use cases". I do feel that's there's two distinct types of svg - "bunch of paths with fills" and "clever dangerous stuff" where most real SVGs are of the former type. Fully expect this to be shot down by someone that's thought about this problem for longer than the 120 seconds I just spent. :) | |||||||||||||||||||||||||||||||||||
| ▲ | pupppet 2 hours ago | parent | next [-] | ||||||||||||||||||||||||||||||||||
This is what happens when there isn't an adult in the room to reign things in, you get project overreach. SVGs should never have supported scripting. You want scripting in SVGs, fine, make it a different file format. I can't imagine the cumulative number of man hours wasted on this problem when the vast majority of users were just looking for a way to make their logos look sharp. | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
| ▲ | afavour 6 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
I think you're right but the lack of industry standard for this kind of thing kills it. People want to be able to take the output of whatever tool they use that exports SVG and put it in a browser. Which isn't an unfair request. But you wouldn't have a guarantee it wouldn't filter out the tool using some obscure SVG functionality. I'd love to see an agreed standard like OpenGL vs OpenGL ES for SVG. SVG-ES. Everyone agrees on the static, non-scripted elements that should work. | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
| ▲ | Avamander 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
There's the SVG Tiny profile that some implementations use, like BIMI/VMCs. | |||||||||||||||||||||||||||||||||||
| ▲ | bawolff 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
> My first thought is "support a tiny subset of svg that probably still covers 90% of real-world use cases". It sounds like the linked post was about someone using a blacklist instead of a whitelist. It doesnt matter how tiny your subset is if you allow through stuff you don't recognize. For the most part svg is safe. The dangerous parts are pretty obvious - script tag, image tag, feImage tag, attributes starting with on, embedding html in <foreignObject>, DTD tricks, namespace tricks, CSS that loads external stuff (keep in mind also presentational attributes. Its not just style attribute/tag). The rest of it is pretty safe. | |||||||||||||||||||||||||||||||||||
| ▲ | hackeman300 6 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
Seems like someone already implemented your idea. https://tinyvg.tech/ | |||||||||||||||||||||||||||||||||||
| ▲ | varun_ch 6 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
I wonder if it would be best if this was at the browser level as some sort of new format. Otherwise surely it would be really slow/cumbersome to deal with these in ‘user space’ | |||||||||||||||||||||||||||||||||||
| ▲ | whycome 6 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
It always seems like any animated svg loses all of the animation after sanitizing | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
| ▲ | harperlee 7 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
Fwiw I just thought the same, parse (don’t validate) the bits you like and recreate / reject the input. | |||||||||||||||||||||||||||||||||||
| ▲ | RobotToaster 5 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
You'd lose a lot of useful features, like SMIL animation. | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
| ▲ | LorenPechtel 6 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||
Yeah, I think that's the real answer. Look at what Microsoft did with Excel--the dangerous stuff is behind a switch. Thus, solution: Add two bits to the tag. SVG1 does not execute any sort of script. SVG2 does not follow links. SVG3 is actually SVG1 + SVG2 as these are bit flags, not numbers. Additional bits are reserved for future use if any other issues are found. The only real safety is in the engine, not by any sanitizer. | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
| ▲ | duped 6 hours ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||
So if you are building something where you control every SVG ever produced and rendered then this is totally reasonable. If you ever need to interface with other tools that generate SVG you now need to have a way of essentially transpiling SVG from the wild into your tamed SVGs. Oftentimes this is done by hand, by a software developer and designer (sometimes the same person). And this is for basic functionality that your designers expect and have trivial controls for in their vector editors, like "add a drop shadow." The article goes into some issues with sanitization itself, and except for <script> these are a bunch of reasonable things that someone might expect to work or not have issues with. Sandboxing rendering isn't an unreasonable approach if you're not writing the parser and renderer yourself. | |||||||||||||||||||||||||||||||||||