Neil's News

Polyglot 8: SVG

2 October 2004

This one was somewhat unexpected. I started implementing the 'colours' application the Moo language, with the output being SVG. Then I discovered that SVG was perfectly capable of generating the pattern all by itself. Who needs the Moo?

SVG is a 2D vector graphics format, it doesn't really like being treated as a bitmap. Thus it takes a little while to render a large grid of pixels. The JavaScript code inside the SVG which does all the computations was lifted straight out of the earlier JavaScript version. SVG is an interesting format, but like all emerging formats it will remain confined to intranets, kiosks and other controlled environments until the majority of browsers can view it.

It would also help if it didn't allow hackers to crash SVG-enabled clients at will. It is trivial to build a memory bomb or infinite loop which crashes Adobe's SVG viewer and its host browser (bug reported to Adobe a week ago, no response received so far, though I'm sure my arrest warrant is in the post as usual). Mozilla is also vulnerable but it takes a bit more work [bug 261974]. I don't know if other implementations (Batik, XML::LibRSVG) are vulnerable.

Here's the SVG source code and a running implementation of the 'colours' program. Currently renders 50 times slower in Mozilla than in IE+Adobe.

< Previous | Next >

 
-------------------------------------
Legal yada yada: My views do not necessarily represent those of my employer or my goldfish.