From fab0ed9a65a451d9a7a3b7ac617a0abc3176049a Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sat, 19 Sep 2020 16:56:21 +0200 Subject: Allow loading SVG files with a doctype declaration SVGs may have a DOCTYPE declaration (https://www.w3.org/TR/2003/REC-SVGMobile-20030114/) in their first line. This patch makes sure those SVGs are loaded properly Fixes: QTBUG-87583 Change-Id: Ia3dcb519b6ee2b498dc81ef496764d99ea6c4a9a Reviewed-by: Eirik Aavitsland Reviewed-by: Robert Loehning Reviewed-by: Volker Hilsheimer (cherry picked from commit 2f63ddc6afeb3d2c3c7a42add0129547acd61ede) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/imageformats/svg/qsvgiohandler.cpp | 8 ++++---- src/svg/qsvgtinydocument.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp index a999d47..5e96d27 100644 --- a/src/plugins/imageformats/svg/qsvgiohandler.cpp +++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp @@ -126,14 +126,14 @@ bool QSvgIOHandler::canRead() const if (d->loaded && !d->readDone) return true; // Will happen if we have been asked for the size - QByteArray buf = device()->peek(8); + QByteArray buf = device()->peek(16); #ifndef QT_NO_COMPRESS if (buf.startsWith("\x1f\x8b")) { setFormat("svgz"); return true; } else #endif - if (buf.contains("peek(8); + QByteArray buf = device->peek(16); return #ifndef QT_NO_COMPRESS buf.startsWith("\x1f\x8b") || #endif - buf.contains("