diff options
author | Nicolas Fella <nicolas.fella@kdab.com> | 2020-09-19 16:56:21 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-10-21 07:57:56 +0000 |
commit | fab0ed9a65a451d9a7a3b7ac617a0abc3176049a (patch) | |
tree | dd271afaf8fc2388c7924126e0a164e16a8f9065 /src/plugins | |
parent | 0afee2870bc4fef180106e80a361da2ef1e3d442 (diff) | |
download | qtsvg-fab0ed9a65a451d9a7a3b7ac617a0abc3176049a.tar.gz |
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 <eirik.aavitsland@qt.io>
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 2f63ddc6afeb3d2c3c7a42add0129547acd61ede)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/imageformats/svg/qsvgiohandler.cpp | 8 |
1 files changed, 4 insertions, 4 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("<?xml") || buf.contains("<svg") || buf.contains("<!--")) { + if (buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--") || buf.contains("<!DOCTYPE svg")) { setFormat("svg"); return true; } @@ -267,12 +267,12 @@ bool QSvgIOHandler::supportsOption(ImageOption option) const bool QSvgIOHandler::canRead(QIODevice *device) { - QByteArray buf = device->peek(8); + QByteArray buf = device->peek(16); return #ifndef QT_NO_COMPRESS buf.startsWith("\x1f\x8b") || #endif - buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--"); + buf.contains("<?xml") || buf.contains("<svg") || buf.contains("<!--") || buf.contains("<!DOCTYPE svg"); } QT_END_NAMESPACE |