From 931294a0f94087630d7e1a34ae93b0560c333b6b Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 10 Feb 2018 16:06:01 -0500 Subject: [PATCH] Validate "encoding" attribute of "image/png" file nodes. --- model/XmlLabelParser.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/model/XmlLabelParser.cpp b/model/XmlLabelParser.cpp index bb34ac4..766457b 100644 --- a/model/XmlLabelParser.cpp +++ b/model/XmlLabelParser.cpp @@ -748,12 +748,19 @@ namespace glabels if ( mimetype == "image/png" ) { - QByteArray ba64 = node.text().toUtf8(); - QByteArray ba = QByteArray::fromBase64( ba64 ); - QImage image; - image.loadFromData( ba, "PNG" ); + if ( encoding == "base64" ) + { + QByteArray ba64 = node.text().toUtf8(); + QByteArray ba = QByteArray::fromBase64( ba64 ); + QImage image; + image.loadFromData( ba, "PNG" ); - data.addImage( name, image ); + data.addImage( name, image ); + } + else + { + qWarning() << "Unexpected encoding:" << encoding << "node:" << node.tagName(); + } } else if ( mimetype == "image/svg+xml" ) {