[Clipart] upload script suggestion
Stephen Silver
ocalocal at btinternet.com
Mon Mar 21 09:16:41 PST 2005
Jonadab wrote:
> "Stephen Silver" <ocalocal at btinternet.com> writes:
> > This line from upload_svg.cgi is surely the culprit:
> >
> > $img =~ s|<$_.*?</$_>||gs for 'metadata', 'rdf:RDF', 'rdf';
> >
> > This line can easily disembowel an SVG file.
>
> At first I thought you might be right, but that's a non-greedy match
> there, so _theoretically_ it should only remove metadata and rdf
> elements and their contents, nothing else.
Not if the SVG file looks like this:
<svg>
<g>
<metadata/>
<!-- image goes here -->
</g>
<metadata>
blah blah
</metadata>
</svg>
This is almost certainly what happened to those images by Christopher
Fynn - his files appear to be made by CorelDRAW, and CorelDRAW really
does write an empty <metadata> tag right after the opening <g> tag,
for example:
<g id="Layer_x0020_1">
<metadata id="CorelCorpID_0Corel-Layer"/>
The only correct thing to do here is to use an XML parser. But as a
quick fix, most of the problems would be avoided if you could modify
the regular expression so that it doesn't match empty tags.
> The input logging I've put in place now should help us diagnose it.
That was quick! Yes, this is better than just saving the SVG files.
--
Stephen Silver
More information about the clipart
mailing list