vcl/qa/cppunit/GraphicTest.cxx | 14 ++++++++++++ vcl/qa/cppunit/data/tdf149545.svg | 32 ++++++++++++++++++++++++++++ vcl/source/filter/GraphicFormatDetector.cxx | 2 - 3 files changed, 47 insertions(+), 1 deletion(-)
New commits: commit f13faf35bc62c9804ecacf2059ad724bc3cb2f24 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue Sep 12 14:29:21 2023 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Sep 19 12:11:30 2023 +0200 tdf#149545: increase svg check size otherwise it will fail to open documents like the one in tdf#149545 with long comments before "<svg" Change-Id: Ia46dad92052ae4ef7fee791098bf96df03257282 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156844 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156876 diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx index 90164c7e317c..da9b8cce449a 100644 --- a/vcl/qa/cppunit/GraphicTest.cxx +++ b/vcl/qa/cppunit/GraphicTest.cxx @@ -86,6 +86,7 @@ private: void testLoadWEBP(); void testLoadSVGZ(); + void testTdf149545(); void testAvailableThreaded(); void testColorChangeToTransparent(); @@ -126,6 +127,7 @@ private: CPPUNIT_TEST(testLoadWEBP); CPPUNIT_TEST(testLoadSVGZ); + CPPUNIT_TEST(testTdf149545); CPPUNIT_TEST(testAvailableThreaded); CPPUNIT_TEST(testColorChangeToTransparent); @@ -1335,6 +1337,18 @@ void GraphicTest::testLoadSVGZ() CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingY), aGraphic.GetSizePixel().Height()); } +void GraphicTest::testTdf149545() +{ + // Without the fix in place, this test would have failed with + // - Expected: 0x0(Error Area:Io Class:NONE Code:0) + // - Actual : 0x8203(Error Area:Vcl Class:General Code:3) + Graphic aGraphic = loadGraphic(u"tdf149545.svg"); + CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType()); + const auto[scalingX, scalingY] = getDPIScaling(); + CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingX), aGraphic.GetSizePixel().Width()); + CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingY), aGraphic.GetSizePixel().Height()); +} + void GraphicTest::testAvailableThreaded() { Graphic jpgGraphic1 = importUnloadedGraphic(u"TypeDetectionExample.jpg"); diff --git a/vcl/qa/cppunit/data/tdf149545.svg b/vcl/qa/cppunit/data/tdf149545.svg new file mode 100644 index 000000000000..39fd956142bd --- /dev/null +++ b/vcl/qa/cppunit/data/tdf149545.svg @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<!--======================================================================--> +<svg version="1.1" baseProfile="basic" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-root" width="100%" height="100%" viewBox="0 0 99 99"> +<rect x="0" y="0" width="99" height="99" fill="#000000"/> +</svg> + + diff --git a/vcl/source/filter/GraphicFormatDetector.cxx b/vcl/source/filter/GraphicFormatDetector.cxx index fc43cdd963ab..d3cb7869ebc1 100644 --- a/vcl/source/filter/GraphicFormatDetector.cxx +++ b/vcl/source/filter/GraphicFormatDetector.cxx @@ -31,7 +31,7 @@ #include <vcl/outdev.hxx> #include <utility> -constexpr sal_uInt32 SVG_CHECK_SIZE = 2048; +constexpr sal_uInt32 SVG_CHECK_SIZE = 8192; constexpr sal_uInt32 WMF_EMF_CHECK_SIZE = 44; constexpr sal_uInt32 DATA_SIZE = 640;