Don't use a secondary XML parser for processing instructions
There is a hack in xml.rs in the parse_xml_stylesheet_processing_instruction
function. When the XML parser (libxml2 in this case) finds a processing instruction, specifically this one:
<?xml-stylesheet type="text/css" alternate="no" href="foo.css" ?>
It gives us just a string with type="text/css" alternate="no" href="foo.css"
, which must be parsed by the calling code. Librsvg builds a string that contains
<rsvg-hack type="text/css" alternate="no" href="foo.css"/>
I.e. a "normal" XML element, and starts a secondary XML parser on it just to extract the attributes/values.
Per the XML spec, the data in the processing instruction is just character data; there's no need to do entity expansion or funky stuff in it. So, I think librsvg could parse it by hand easily instead of using an XML parser as a hack.
For reference, this is the XML stylesheet spec.
Edited by Federico Mena Quintero