GNOME Bugzilla – Bug 567311
fails to parse SVG with parameter entities
Last modified: 2011-04-16 20:02:18 UTC
First: $ cat test1.svg [http://www.gnome.org/~chpe/testcases/test1.svg] <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3org/Graphics/SVG/1.1/DTD/svg11.dtd" [ <!ENTITY mytext "Hello"> ]> <svg xmlns="http://www.w3.org/2000/svg" width="20mm" height="20mm"> <g> <text x="10" y="10">&mytext;</text> </g> </svg> $ rsvg-view test1.svg Shows the expected result, with the text being "Hello". Now this: $ cat test2.svg [http://www.gnome.org/~chpe/testcases/test2.svg] <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3org/Graphics/SVG/1.1/DTD/svg11.dtd" [ <!ENTITY % mydecls SYSTEM "test2.dtd"> %mydecls; ]> <svg xmlns="http://www.w3.org/2000/svg" width="20mm" height="20mm"> <g> <text x="10" y="10">&mytext;</text> </g> </svg> $ cat test2.dtd [http://www.gnome.org/~chpe/testcases/test2.dtd] <!ENTITY mytext "Hello"> $ xmllint test2.svg && echo valid <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3org/Graphics/SVG/1.1/DTD/svg11.dtd" [ <!ENTITY % mydecls SYSTEM "test2.dtd"> <!ENTITY mytext "Hello"> ]> <svg xmlns="http://www.w3.org/2000/svg" width="20mm" height="20mm"> <g> <text x="10" y="10">&mytext;</text> </g> </svg> valid So this is valid XML. However: $ rsvg-view test2.svg Error displaying image: Error domain 1 code 27 on line 8 column 23 of file:///opt/source/_git/librsvg/testcases-chpe/test2.svg: Entity 'mytext' not defined (That means domain=XML_FROM_PARSER, code=XML_WAR_UNDECLARED_ENTITY) Inkscape loads & displays test2.svg just fine (doesn't write back the entities though when saving).
Created attachment 126306 [details] [review] patch This makes test2.svg work. Not sure if it's really the right way though... comments?