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 235ebd321bb89f0c1c103c4c7ae88f9ddf291a7f
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Sep 12 14:29:21 2023 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Sep 12 23:00:38 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/+/156862

diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 2dff15f29d34..0acd4a2cf783 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);
 
@@ -1309,6 +1311,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 1a216bb1db92..e718b883d8bc 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;
 
 namespace

Reply via email to