From: Caolán McNamara Date: Fri, 3 Nov 2023 17:14:26 +0000 (+0000) Subject: add some protocols that don't make sense as floating frame targets X-Git-Tag: archive/raspbian/1%7.0.4-4+rpi1+deb11u13^2~17 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f30103d1d2b19f001a8025c5a8df9822bee8c287;p=libreoffice.git add some protocols that don't make sense as floating frame targets Change-Id: Id900a5eef248731d1184c1df501a2cf7a2de7eb9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158910 Tested-by: Jenkins Reviewed-by: Caolán McNamara (cherry picked from commit 11ebdfef16501c6d35c3e3d0d62507f706557c71) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158900 Reviewed-by: Michael Stahl (cherry picked from commit bab433911bdecb344f7ea94dbd00690241a08c54) Gbp-Pq: Name floating-frame-targets-unneeded-protocols.diff --- diff --git a/include/tools/urlobj.hxx b/include/tools/urlobj.hxx index 1fb5f4e86ae..66c562f9006 100644 --- a/include/tools/urlobj.hxx +++ b/include/tools/urlobj.hxx @@ -920,6 +920,11 @@ public: void changeScheme(INetProtocol eTargetScheme); + // INetProtocol::Macro, INetProtocol::Uno, INetProtocol::Slot, + // vnd.sun.star.script, etc. All the types of URLs which shouldn't + // be accepted from an outside controlled source + bool IsExoticProtocol() const; + private: // General Structure: diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index ea90c4db3b0..9709bd91c44 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -167,8 +168,11 @@ sal_Bool SAL_CALL IFrameObject::load( xTrans->parseStrict( aTargetURL ); INetURLObject aURLObject(aTargetURL.Complete); - if (aURLObject.GetProtocol() == INetProtocol::Macro || aURLObject.isSchemeEqualTo(u"vnd.sun.star.script")) + if (aURLObject.IsExoticProtocol()) + { + SAL_WARN("sfx", "IFrameObject::load ignoring: " << aTargetURL.Complete); return false; + } uno::Reference xParentFrame = xFrame->getCreator(); SfxObjectShell* pDoc = SfxMacroLoader::GetObjectShell(xParentFrame); diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index 8818f548da2..8e6bdfd9884 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -4760,4 +4760,12 @@ OUString INetURLObject::CutExtension() ? aTheExtension : OUString(); } +bool INetURLObject::IsExoticProtocol() const +{ + return m_eScheme == INetProtocol::Slot || + m_eScheme == INetProtocol::Macro || + m_eScheme == INetProtocol::Uno || + isSchemeEqualTo(u"vnd.sun.star.script"); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */