[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - svgio/inc svgio/source
svgio/inc/svgstyleattributes.hxx |2 svgio/source/svgreader/svgstyleattributes.cxx | 184 +- 2 files changed, 94 insertions(+), 92 deletions(-) New commits: commit bcc2e360d59532ccf4daac81174ef464abe3290d Author: Caolán McNamara AuthorDate: Thu Aug 30 14:05:20 2018 +0100 Commit: Caolán McNamara CommitDate: Fri Aug 31 09:27:51 2018 +0200 tdf#119557 style hierarchy isn't stable so looping check fails falsely Given the css stuff a given style can end up with itself as a grandparent but then the css mutates things so it doesn't loop around to give itself as a grandgrandparent. So undo the loop detection check and turn it into a parse depth test instead with an arbitrary, but high, level Change-Id: If28684ad2b2adc664bc2da6b176b93248b377162 Reviewed-on: https://gerrit.libreoffice.org/59814 Reviewed-by: Michael Stahl Tested-by: Jenkins diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx index 44f4d35ab9b4..a024dc68b789 100644 --- a/svgio/inc/svgstyleattributes.hxx +++ b/svgio/inc/svgstyleattributes.hxx @@ -231,7 +231,7 @@ namespace svgio BaselineShift maBaselineShift; SvgNumber maBaselineShiftNumber; -mutable boolmbResolvingParent; +mutable std::vector maResolvingParent; // defines if this attributes are part of a ClipPath. If yes, // rough geometry will be created on decomposition by patching diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index d34bccb03fc0..c0c23e411420 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -40,6 +40,8 @@ #include #include +const int nStyleDepthLimit = 1024; + namespace svgio { namespace svgreader @@ -1289,7 +1291,7 @@ namespace svgio maClipRule(FillRule_nonzero), maBaselineShift(BaselineShift_Baseline), maBaselineShiftNumber(0), -mbResolvingParent(false), +maResolvingParent(30, 0), mbIsClipPathContent(SVGTokenClipPathNode == mrOwner.getType()), mbStrokeDasharraySet(false) { @@ -2029,11 +2031,11 @@ namespace svgio { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); -if (pSvgStyleAttributes && !mbResolvingParent) +if (pSvgStyleAttributes && maResolvingParent[0] < nStyleDepthLimit) { -mbResolvingParent = true; +++maResolvingParent[0]; const basegfx::BColor* pFill = pSvgStyleAttributes->getFill(); -mbResolvingParent = false; +--maResolvingParent[0]; if(mbIsClipPathContent) { @@ -2074,11 +2076,11 @@ namespace svgio { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); -if (pSvgStyleAttributes && !mbResolvingParent) +if (pSvgStyleAttributes && maResolvingParent[1] < nStyleDepthLimit) { -mbResolvingParent = true; +++maResolvingParent[1]; auto ret = pSvgStyleAttributes->getStroke(); -mbResolvingParent = false; +--maResolvingParent[1]; return ret; } } @@ -2108,11 +2110,11 @@ namespace svgio { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); -if (pSvgStyleAttributes && !mbResolvingParent) +if (pSvgStyleAttributes && maResolvingParent[2] < nStyleDepthLimit) { -mbResolvingParent = true; +++maResolvingParent[2]; auto ret = pSvgStyleAttributes->getSvgGradientNodeFill(); -mbResolvingParent = false; +--maResolvingParent[2]; return ret; } } @@ -2130,11 +2132,11 @@ namespace svgio { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); -if (pSvgStyleAttributes && !mbResolvingParent) +if (pSvgStyleAttributes && maResolvingParent[3] < nStyleDepthLimit) { -mbResolvingParent = true; +++maResolvingParent[3]; auto ret = pSvgStyleAttributes->getSvgGradientNodeStroke(); -mbResolvingParent = false; +--maResolvingParent[3]; return ret; } } @@ -2152,11 +2154,11 @@ namespace svgio { const SvgStyleAttributes*
[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - svgio/inc svgio/source
svgio/inc/svgpatternnode.hxx |1 svgio/source/svgreader/svgpatternnode.cxx | 71 +- 2 files changed, 52 insertions(+), 20 deletions(-) New commits: commit e54b0a2ada74713a9906838d60b38df6d464bacd Author: Caolán McNamara AuthorDate: Mon Jul 23 16:10:08 2018 +0100 Commit: Michael Stahl CommitDate: Thu Jul 26 11:24:19 2018 +0200 crashtesting: infinite recurse with moz455984-5.svg Change-Id: Idef368c44454ae144b091132cd0d6103f92a6dde Reviewed-on: https://gerrit.libreoffice.org/57855 Tested-by: Jenkins Reviewed-by: Michael Stahl diff --git a/svgio/inc/svgpatternnode.hxx b/svgio/inc/svgpatternnode.hxx index 5aa93b373217..956c8da1812e 100644 --- a/svgio/inc/svgpatternnode.hxx +++ b/svgio/inc/svgpatternnode.hxx @@ -55,6 +55,7 @@ namespace svgio /// link to another pattern used as style. If maXLink /// is set, the node can be fetched on demand by using // tryToFindLink (buffered) +mutable bool mbResolvingLink; // protect against infinite link recursion OUString maXLink; const SvgPatternNode* mpXLink; diff --git a/svgio/source/svgreader/svgpatternnode.cxx b/svgio/source/svgreader/svgpatternnode.cxx index 758a6022f841..5b3d2d726abe 100644 --- a/svgio/source/svgreader/svgpatternnode.cxx +++ b/svgio/source/svgreader/svgpatternnode.cxx @@ -47,6 +47,7 @@ namespace svgio mpPatternUnits(nullptr), mpPatternContentUnits(nullptr), mpaPatternTransform(nullptr), +mbResolvingLink(false), maXLink(), mpXLink(nullptr) { @@ -271,9 +272,12 @@ namespace svgio { const_cast< SvgPatternNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getPatternPrimitives(); +mbResolvingLink = true; +const drawinglayer::primitive2d::Primitive2DContainer& ret = mpXLink->getPatternPrimitives(); +mbResolvingLink = false; +return ret; } } @@ -301,9 +305,12 @@ namespace svgio const_cast< SvgPatternNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getViewBox(); +mbResolvingLink = true; +auto ret = mpXLink->getViewBox(); +mbResolvingLink = false; +return ret; } return nullptr; @@ -318,9 +325,12 @@ namespace svgio const_cast< SvgPatternNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getSvgAspectRatio(); +mbResolvingLink = true; +const SvgAspectRatio& ret = mpXLink->getSvgAspectRatio(); +mbResolvingLink = false; +return ret; } return maSvgAspectRatio; @@ -335,9 +345,12 @@ namespace svgio const_cast< SvgPatternNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getX(); +mbResolvingLink = true; +const SvgNumber& ret = mpXLink->getX(); +mbResolvingLink = false; +return ret; } return maX; @@ -352,9 +365,12 @@ namespace svgio const_cast< SvgPatternNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getY(); +mbResolvingLink = true; +const SvgNumber& ret = mpXLink->getY(); +mbResolvingLink = false; +return ret; } return maY; @@ -369,9 +385,12 @@ namespace svgio const_cast< SvgPatternNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getWidth(); +mbResolvingLink = true; +const SvgNumber& ret = mpXLink->getWidth(); +mbResolvingLink = false; +return ret; } return maWidth; @@ -386,9 +405,12 @@ namespace svgio const_cast< SvgPatternNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getHeight(); +mbResolvingLink = true; +const SvgNumber& ret = mpXLink->getHeight(); +mbResolvingLink = false; +return ret; } return maHeight; @@
[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - svgio/inc svgio/source
svgio/inc/svgstyleattributes.hxx |1 svgio/source/svgreader/svgstyleattributes.cxx | 199 ++ 2 files changed, 144 insertions(+), 56 deletions(-) New commits: commit b37e31e9537fe5437809bc711edc01b6442b7bae Author: Caolán McNamara AuthorDate: Mon Jul 23 17:37:04 2018 +0100 Commit: Michael Stahl CommitDate: Thu Jul 26 11:17:04 2018 +0200 crashtesting: infinite recurse with moz609361-1.svg Change-Id: I18c2dd159dd7a64c3627abdb472d65013453b1b9 Reviewed-on: https://gerrit.libreoffice.org/57892 Tested-by: Jenkins Reviewed-by: Michael Stahl diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx index c642f169f9c6..44f4d35ab9b4 100644 --- a/svgio/inc/svgstyleattributes.hxx +++ b/svgio/inc/svgstyleattributes.hxx @@ -231,6 +231,7 @@ namespace svgio BaselineShift maBaselineShift; SvgNumber maBaselineShiftNumber; +mutable boolmbResolvingParent; // defines if this attributes are part of a ClipPath. If yes, // rough geometry will be created on decomposition by patching diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index 2d96cfb9d022..d34bccb03fc0 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -1289,6 +1289,7 @@ namespace svgio maClipRule(FillRule_nonzero), maBaselineShift(BaselineShift_Baseline), maBaselineShiftNumber(0), +mbResolvingParent(false), mbIsClipPathContent(SVGTokenClipPathNode == mrOwner.getType()), mbStrokeDasharraySet(false) { @@ -2028,9 +2029,11 @@ namespace svgio { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); -if(pSvgStyleAttributes) +if (pSvgStyleAttributes && !mbResolvingParent) { +mbResolvingParent = true; const basegfx::BColor* pFill = pSvgStyleAttributes->getFill(); +mbResolvingParent = false; if(mbIsClipPathContent) { @@ -2071,9 +2074,12 @@ namespace svgio { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); -if(pSvgStyleAttributes) +if (pSvgStyleAttributes && !mbResolvingParent) { -return pSvgStyleAttributes->getStroke(); +mbResolvingParent = true; +auto ret = pSvgStyleAttributes->getStroke(); +mbResolvingParent = false; +return ret; } } @@ -2102,9 +2108,12 @@ namespace svgio { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); -if(pSvgStyleAttributes) +if (pSvgStyleAttributes && !mbResolvingParent) { -return pSvgStyleAttributes->getSvgGradientNodeFill(); +mbResolvingParent = true; +auto ret = pSvgStyleAttributes->getSvgGradientNodeFill(); +mbResolvingParent = false; +return ret; } } @@ -2121,9 +2130,12 @@ namespace svgio { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); -if(pSvgStyleAttributes) +if (pSvgStyleAttributes && !mbResolvingParent) { -return pSvgStyleAttributes->getSvgGradientNodeStroke(); +mbResolvingParent = true; +auto ret = pSvgStyleAttributes->getSvgGradientNodeStroke(); +mbResolvingParent = false; +return ret; } } @@ -2140,9 +2152,12 @@ namespace svgio { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); -if(pSvgStyleAttributes) +if (pSvgStyleAttributes && !mbResolvingParent) { -return pSvgStyleAttributes->getSvgPatternNodeFill(); +mbResolvingParent = true; +auto ret = pSvgStyleAttributes->getSvgPatternNodeFill(); +mbResolvingParent = false; +return ret; } } @@ -2159,9 +2174,12 @@ namespace svgio { const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle(); -if(pSvgStyleAttributes) +if (pSvgStyleAttributes && !mbResolvingParent) { -return pSvgStyleAttributes->getSvgPatternNodeStroke(); +mbResolvingParent = true; +
[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - svgio/inc svgio/source
svgio/inc/svgnode.hxx |2 ++ svgio/source/svgreader/svgnode.cxx |7 +++ 2 files changed, 9 insertions(+) New commits: commit 741c72ebdfec5fc7e0343c050214509009a03636 Author: Caolán McNamara AuthorDate: Mon Jul 23 21:30:05 2018 +0100 Commit: Eike Rathke CommitDate: Thu Jul 26 01:13:37 2018 +0200 crashtesting: infinite recurse with moz384637-1.svg Change-Id: Ia4bbc9d471c63812dc3ef490f32e8490bda72bfe Reviewed-on: https://gerrit.libreoffice.org/57889 Tested-by: Jenkins Reviewed-by: Eike Rathke diff --git a/svgio/inc/svgnode.hxx b/svgio/inc/svgnode.hxx index 45d9730be909..2db5d490fa14 100644 --- a/svgio/inc/svgnode.hxx +++ b/svgio/inc/svgnode.hxx @@ -114,6 +114,8 @@ namespace svgio /// possible local CssStyle, e.g. style="fill:red; stroke:red;" std::unique_ptrmpLocalCssStyle; +mutable boolmbDecomposing; + // flag if maCssStyleVector is already computed (done only once) boolmbCssStyleVectorBuilt : 1; diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx index f6395a24527d..56389ef14124 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -267,6 +267,7 @@ namespace svgio maDisplay(Display_inline), maCssStyleVector(), mpLocalCssStyle(nullptr), +mbDecomposing(false), mbCssStyleVectorBuilt(false) { OSL_ENSURE(SVGTokenUnknown != maType, "SvgNode with unknown type created (!)"); @@ -464,6 +465,9 @@ namespace svgio void SvgNode::decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const { +if (mbDecomposing) //guard against infinite recurse +return; + if(Display_none == getDisplay()) { return; @@ -499,6 +503,8 @@ namespace svgio if(!rChildren.empty()) { +mbDecomposing = true; + const sal_uInt32 nCount(rChildren.size()); for(sal_uInt32 a(0); a < nCount; a++) @@ -571,6 +577,7 @@ namespace svgio } } } +mbDecomposing = false; } } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - svgio/inc svgio/source
svgio/inc/svggradientnode.hxx |1 svgio/source/svgreader/svggradientnode.cxx | 75 - 2 files changed, 55 insertions(+), 21 deletions(-) New commits: commit b59d639a5fbbddd976d6c79ea12460b553426887 Author: Caolán McNamara AuthorDate: Wed Jul 18 12:12:05 2018 +0100 Commit: Michael Meeks CommitDate: Wed Jul 18 22:31:11 2018 +0200 crashtesting: infinite recurse on moz330387-6.svg Change-Id: I3c39d49504a4651b92f41c07e4cef8887366dc2b Reviewed-on: https://gerrit.libreoffice.org/57627 Tested-by: Jenkins Reviewed-by: Michael Meeks diff --git a/svgio/inc/svggradientnode.hxx b/svgio/inc/svggradientnode.hxx index 3710519dc392..1542796b48fc 100644 --- a/svgio/inc/svggradientnode.hxx +++ b/svgio/inc/svggradientnode.hxx @@ -56,6 +56,7 @@ namespace svgio /// link to another gradient used as style. If maXLink /// is set, the node can be fetched on demand by using // tryToFindLink (buffered) +mutable bool mbResolvingLink; // protect against infinite link recursion OUString maXLink; const SvgGradientNode* mpXLink; diff --git a/svgio/source/svgreader/svggradientnode.cxx b/svgio/source/svgreader/svggradientnode.cxx index 4496a809a8cf..efbfdccaadb5 100644 --- a/svgio/source/svgreader/svggradientnode.cxx +++ b/svgio/source/svgreader/svggradientnode.cxx @@ -51,6 +51,7 @@ namespace svgio maGradientUnits(objectBoundingBox), maSpreadMethod(drawinglayer::primitive2d::SpreadMethod::Pad), mpaGradientTransform(nullptr), +mbResolvingLink(false), maXLink(), mpXLink(nullptr) { @@ -246,9 +247,11 @@ namespace svgio { const_cast< SvgGradientNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { +mbResolvingLink = true; mpXLink->collectGradientEntries(aVector); +mbResolvingLink = false; } } else @@ -312,9 +315,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getX1(); +mbResolvingLink = true; +auto ret = mpXLink->getX1(); +mbResolvingLink = false; +return ret; } // default is 0% @@ -330,9 +336,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getY1(); +mbResolvingLink = true; +auto ret = mpXLink->getY1(); +mbResolvingLink = false; +return ret; } // default is 0% @@ -348,9 +357,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getX2(); +mbResolvingLink = true; +auto ret = mpXLink->getX2(); +mbResolvingLink = false; +return ret; } // default is 100% @@ -366,9 +378,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getY2(); +mbResolvingLink = true; +auto ret = mpXLink->getY2(); +mbResolvingLink = false; +return ret; } // default is 0% @@ -384,9 +399,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getCx(); +mbResolvingLink = true; +auto ret = mpXLink->getCx(); +mbResolvingLink = false; +return ret; } // default is 50% @@ -402,9 +420,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink && !mbResolvingLink) { -return mpXLink->getCy(); +mbResolvingLink = true; +auto ret = mpXLink->getCy(); +mbResolvingLink = false; +return ret; } // default is 50% @@ -420,9 +441,12 @@ namespace svgio const_cast< SvgGradientNode* >(this)->tryToFindLink(); -if(mpXLink) +if (mpXLink &&