3 ms·
Many of your concerns are addressed by 2.0, go give it a look. > On this way you avoid all the common XML pitfalls like xml entities blowing up your memory. D
by dietrichepp 10y ago
Many of your concerns are addressed by 2.0, go give it a look.
> On this way you avoid all the common XML pitfalls like xml entities blowing up your memory.
DTDs are gone, and with them, entity definitions. This particular attack is no longer possible in SVG 2.0.
> So you walk down your SVG DOM and begin to parse path data strings. The syntax seems understandable after a short while so you think you can easily write a parser. But the parser you'll write will be wrong because the details of the syntax are totally arcane, whitespace can sometimes be dropped (e.g. A.5.5.5 10.5.5 is the same as A 0.5 0.5 0.5 1 0 0.5 0.5), commas are allowed at some places but only one at most.
The data strings—sure, their syntax could be more natural, yes. But it's certainly not difficult to parse a data string if you pay close attention to the spec. These specs aren't the kind of thing that random programmers should be implementing anyway, you'll want a proper SVG library to parse the SVG for you, and the SVG library will come with a test suite. This is no different than the way we parse JSON or HTML—we farm it out to libraries because it's easy to get it wrong.
But most text standards will produce a few broken implementations, SVG is no different. HTML parsers have disagreed since the beginning of time, there were recently some exploits for non-compliant URI parsers, and people have often forgotten the weird way you encode supplementary plane characters in JSON. Heck, if you look at "plain text" we can see a history of buggy programs, such as the NUL bytes that appeared in filenames for a buggy NFS server or the C0 AF directory traversal attack.
> So the next element you want to render is a text element, which is a huge joke because it doesn't even support multi-line text…
Multi-line text is a feature of SVG 2.0.
> I really don't see how adding new features makes any of this easier, when SVG 2.0 is basically a backwards-compatible superset.
2.0 is not a superset.
Again, you may want to take a look at the linked article at the top. Check out the section titled "Removed". It includes non-trivial chunks of functionality like the DTD, which vastly simplifies the parser. SVG fonts are also removed, which is a big chunk of complexity.
Yes, if you're writing your own SVG parser, it can be a bit daunting, just like writing your own HTML parser. But removing the DTD and fonts is a win in terms of reduced complexity, and moving more attributes to styles reduce the complexity of making animations from the user's perspective.
For me, SVG will continue to be an essential part of the web. Maybe you won't use it for "images" per se, at least not the way you embed JPEG and PNG files into your web pages, but you'll still be using it if you use D3 or the other cool drawing libraries for HTML. Canvas isn't always the right tool for the job. Or, put it this way. SVG isn't just an alternative to PNG, it's an alternative to <canvas>.
- legulere 10y agoMy general point is that SVG is an extremely complex format and that its complexity is preventing further adoption. Removing SVG fonts isn't going to change anything about that, as nobody but webkit bothered to implement it anyway. > This particular attack is no longer possible in SVG 2.0. You still need to configure your xml parser the correct way, this doesn't really change anything. > But it's certainly not difficult to parse a data string if you pay close attention to the spec. Or you just change the spec to follow the buggy behaviour when a few implementation have the same bug: https://lists.w3.org/Archives/Public/www-svg/2010Apr/0042.html https://lists.w3.org/Archives/Public/www-svg/2010Apr/0042.ht... which leads to new bugs https://bugs.launchpad.net/inkscape/+bug/1284409 https://bugs.launchpad.net/inkscape/+bug/1284409 I think the amount of issues you can find around svg paths with a bit of googling make a pretty good case that the format is overly complex.
- dietrichepp 10y agoI really don't know what that "further adoption" you're talking about because it's on all major browsers. caniuse.com marks SVG support on 97% of clients worldwide.
- legulere 10y agoYou can't really use SVGs, except on the web. MS office, latex, ... all need conversion. This seems a minor issue at first, but companies will simply not bother converting their logos to SVGs for the web then. Even on the web wikipedia prerenders als svgs to have uniform look of them on all browsers, image hosters don't support them (probably because they could contain javascript), when I see something that looks like a vector graphic on the web it's >90% of the time a png.
- dietrichepp 10y agoWell, yeah. You also can't really use HTML except on the web. SVG and HTML are both formats that are most at home on the web and in a web browser. It does that job well. It does a lot of things that are impossible or cumbersome in PNGs. PNGs are good enough for logos, I don't see why you would care either way.