diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-07-06 16:52:38 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-07-06 20:34:03 +0200 |
commit | d291957dce7a5af17717125cce974a2d2dd9d5b0 (patch) | |
tree | 4c47549d03419210c928ee111a460cf3bcbb44cf /svgio | |
parent | 9d4881392eded9081228509769f94538c38646b8 (diff) |
tdf#149880: handle url when it's inside the quotation marks
Change-Id: I053323f9b48c8856d520095da0a4768ac03b0176
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136847
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r-- | svgio/qa/cppunit/SvgImportTest.cxx | 22 | ||||
-rw-r--r-- | svgio/qa/cppunit/data/tdf149880.svg | 11 | ||||
-rw-r--r-- | svgio/source/svgreader/svgtools.cxx | 13 |
3 files changed, 44 insertions, 2 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index 4b5af1e54d84..5c041ac3b386 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -70,6 +70,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools void testTdf94765(); void testBehaviourWhenWidthAndHeightIsOrIsNotSet(); void testTdf97663(); + void testTdf149880(); void testCssClassRedefinition(); Primitive2DSequence parseSvg(std::u16string_view aSource); @@ -107,6 +108,7 @@ public: CPPUNIT_TEST(testTdf94765); CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet); CPPUNIT_TEST(testTdf97663); + CPPUNIT_TEST(testTdf149880); CPPUNIT_TEST(testCssClassRedefinition); CPPUNIT_TEST_SUITE_END(); }; @@ -835,6 +837,26 @@ void Test::testTdf97663() assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "y", "236"); } +void Test::testTdf149880() +{ + Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf149880.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequence)); + + CPPUNIT_ASSERT (pDocument); + + // Without the fix in place, this test would have failed with + // - Expected: 1 + // - Actual : 0 + // - In <>, XPath '/primitive2D/transform/mask/unhandled' number of nodes is incorrect + assertXPath(pDocument, + "/primitive2D/transform/mask/unhandled", "id", "PATTERNFILL"); + assertXPath(pDocument, + "/primitive2D/transform/mask/unhandled/mask/transform/transform/bitmap", 28); +} + void Test::testCssClassRedefinition() { // Tests for svg css class redefinition behavior diff --git a/svgio/qa/cppunit/data/tdf149880.svg b/svgio/qa/cppunit/data/tdf149880.svg new file mode 100644 index 000000000000..08ba748487cb --- /dev/null +++ b/svgio/qa/cppunit/data/tdf149880.svg @@ -0,0 +1,11 @@ +<?xml version="1.0" standalone="no"?> +<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" version="1.1"> + <defs> + <pattern id="Pattern" x=".05" y=".05" width=".25" height=".25"> + <rect x="0" y="0" width="50" height="50" fill="skyblue"/> + </pattern> + + </defs> + + <rect fill='url("#Pattern")' stroke="black" x="0" y="0" width="200" height="200"/> +</svg> diff --git a/svgio/source/svgreader/svgtools.cxx b/svgio/source/svgreader/svgtools.cxx index 9ba7f1d47952..4ae287784d8c 100644 --- a/svgio/source/svgreader/svgtools.cxx +++ b/svgio/source/svgreader/svgtools.cxx @@ -1072,9 +1072,18 @@ namespace svgio::svgreader const sal_Int32 nLen(rCandidate.getLength()); sal_Int32 nPos(strlen(aStrUrl)); - skip_char(rCandidate, '(', '#', nPos, nLen); + skip_char(rCandidate, '(', nPos, nLen); + sal_Unicode aLimiter(')'); + + if('"' == rCandidate[nPos]) + aLimiter = '"'; + + skip_char(rCandidate, '"', nPos, nLen); + skip_char(rCandidate, '#', nPos, nLen); OUStringBuffer aTokenValue; - copyToLimiter(rCandidate, ')', nPos, aTokenValue, nLen); + + copyToLimiter(rCandidate, aLimiter, nPos, aTokenValue, nLen); + rURL = aTokenValue.makeStringAndClear(); return true; |