The Birdfont Source Code


All Repositories / birdfont.git / commit – 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
author Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 20 Dec 2015 21:12:33 +0000 (22:12 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sun, 20 Dec 2015 21:12:33 +0000 (22:12 +0100)
commit 1b39556e86ff4035172b75fab3a8a03ddd854b56
tree 461be4ceb0f48d0a5dab38708d11b896b875a4f5
parent 03b17785881fdc17f3afee3e404d8b6ec4357435
Validate XML when importing SVG file

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();