diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2021-04-08 13:19:52 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-04-08 20:08:06 +0000 |
commit | e0dd65ea8584f006281e931de041b79b16de0cf4 (patch) | |
tree | ff01fe33e22cc8459cdadfd7104770bd4f87cb71 /tests | |
parent | 432a45ec123a22fc1f458475f99b99364459e07d (diff) | |
download | qtsvg-e0dd65ea8584f006281e931de041b79b16de0cf4.tar.gz |
Make image handler accept UTF-16/UTF-32 encoded SVGs
The canRead() header checks assumed 8 bit encoding.
Fixes: QTBUG-90744
Change-Id: Ibe934fe9ed31b89ee0fbfc4562aa66ab1b359225
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 45fb1f07eaa984af40fca9f12b8f3d27f7b0e9ac)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qsvgplugin/simple_Utf16BE.svg | bin | 0 -> 228 bytes | |||
-rw-r--r-- | tests/auto/qsvgplugin/simple_Utf16LE.svg | bin | 0 -> 228 bytes | |||
-rw-r--r-- | tests/auto/qsvgplugin/simple_Utf32BE.svg | bin | 0 -> 456 bytes | |||
-rw-r--r-- | tests/auto/qsvgplugin/simple_Utf32LE.svg | bin | 0 -> 456 bytes | |||
-rw-r--r-- | tests/auto/qsvgplugin/simple_Utf8.svg | 3 | ||||
-rw-r--r-- | tests/auto/qsvgplugin/tst_qsvgplugin.cpp | 32 |
6 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qsvgplugin/simple_Utf16BE.svg b/tests/auto/qsvgplugin/simple_Utf16BE.svg Binary files differnew file mode 100644 index 0000000..c3312cb --- /dev/null +++ b/tests/auto/qsvgplugin/simple_Utf16BE.svg diff --git a/tests/auto/qsvgplugin/simple_Utf16LE.svg b/tests/auto/qsvgplugin/simple_Utf16LE.svg Binary files differnew file mode 100644 index 0000000..cdbeda9 --- /dev/null +++ b/tests/auto/qsvgplugin/simple_Utf16LE.svg diff --git a/tests/auto/qsvgplugin/simple_Utf32BE.svg b/tests/auto/qsvgplugin/simple_Utf32BE.svg Binary files differnew file mode 100644 index 0000000..0d5d02c --- /dev/null +++ b/tests/auto/qsvgplugin/simple_Utf32BE.svg diff --git a/tests/auto/qsvgplugin/simple_Utf32LE.svg b/tests/auto/qsvgplugin/simple_Utf32LE.svg Binary files differnew file mode 100644 index 0000000..58a7159 --- /dev/null +++ b/tests/auto/qsvgplugin/simple_Utf32LE.svg diff --git a/tests/auto/qsvgplugin/simple_Utf8.svg b/tests/auto/qsvgplugin/simple_Utf8.svg new file mode 100644 index 0000000..2052c48 --- /dev/null +++ b/tests/auto/qsvgplugin/simple_Utf8.svg @@ -0,0 +1,3 @@ +<svg version="1.0" xmlns="http://www.w3.org/2000/svg"> + <circle cx="50" cy="50" r="25" fill="#00ff00" /> +</svg> diff --git a/tests/auto/qsvgplugin/tst_qsvgplugin.cpp b/tests/auto/qsvgplugin/tst_qsvgplugin.cpp index 95f37eb..927e73f 100644 --- a/tests/auto/qsvgplugin/tst_qsvgplugin.cpp +++ b/tests/auto/qsvgplugin/tst_qsvgplugin.cpp @@ -60,6 +60,8 @@ private slots: void checkSize_data(); void checkSize(); void checkImageInclude(); + void encodings_data(); + void encodings(); }; @@ -144,6 +146,36 @@ void tst_QSvgPlugin::checkImageInclude() logMessages.clear(); } +void tst_QSvgPlugin::encodings_data() +{ + QTest::addColumn<QString>("filename"); + + QTest::newRow("utf-8") << QFINDTESTDATA("simple_Utf8.svg"); + QTest::newRow("utf-16LE") << QFINDTESTDATA("simple_Utf16LE.svg"); + QTest::newRow("utf-16BE") << QFINDTESTDATA("simple_Utf16BE.svg"); + QTest::newRow("utf-32LE") << QFINDTESTDATA("simple_Utf32LE.svg"); + QTest::newRow("utf-32BE") << QFINDTESTDATA("simple_Utf32BE.svg"); +} + +void tst_QSvgPlugin::encodings() +{ + QFETCH(QString, filename); + + { + QFile file(filename); + file.open(QIODevice::ReadOnly); + QVERIFY(QSvgIOHandler::canRead(&file)); + } + + QFile file(filename); + file.open(QIODevice::ReadOnly); + QSvgIOHandler plugin; + plugin.setDevice(&file); + QVERIFY(plugin.canRead()); + QImage img; + QVERIFY(plugin.read(&img)); + QCOMPARE(img.size(), QSize(50, 50)); +} QTEST_MAIN(tst_QSvgPlugin) #include "tst_qsvgplugin.moc" |