The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Validate XML when importing SVG file

These changes was commited to the Birdfont repository Sun, 20 Dec 2015 21:12:33 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Sun, 20 Dec 2015 21:12:33 +0000]

Updated Files

libbirdfont/Glyph.vala
libbirdfont/OpenFontFormat/SvgTable.vala
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -15,6 +15,7 @@ using Cairo; using Math; using Gee; + using B; namespace BirdFont { @@ -153,6 +154,13 @@ set { try { if (value != null) { + XmlParser xml = new XmlParser ((!) value); + + if (!xml.validate ()) { + warning("Invalid SVG data, skipping import."); + return; + } + uint8[] svg_array = ((!) value).data; svg_drawing = new Rsvg.Handle.from_data (svg_array); } else {
--- a/libbirdfont/OpenFontFormat/SvgTable.vala +++ b/libbirdfont/OpenFontFormat/SvgTable.vala @@ -70,12 +70,13 @@ svg_tags = new Gee.ArrayList<Tag> (); meta = new Gee.ArrayList<Tag> (); xml = new XmlParser (svg_data); - svg_root_tag = xml.get_root_tag (); if (!xml.validate ()) { warning("Invalid SVG data in TTF table."); return; } + + svg_root_tag = xml.get_root_tag (); foreach (Tag tag in svg_root_tag) { string name = tag.get_name();