[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - include/sfx2 sfx2/source svx/source sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Jul 18 19:21:47 UTC 2018


 include/sfx2/linkmgr.hxx            |    7 ++++---
 sfx2/source/appl/linkmgr2.cxx       |   11 +++++++----
 svx/source/svdraw/svdograf.cxx      |    2 +-
 sw/source/core/docnode/swbaslnk.cxx |    9 ++++++++-
 4 files changed, 20 insertions(+), 9 deletions(-)

New commits:
commit 6f521b2d4e2a68d29839012f73dec45e68aeaef1
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jul 17 09:08:51 2018 +0100
Commit:     Eike Rathke <erack at redhat.com>
CommitDate: Wed Jul 18 21:21:23 2018 +0200

    bubble referer to LinkManager::GetGraphicFromAny
    
    Change-Id: Id2c6d629692a365f96f3f81c5686930668389a6a
    Reviewed-on: https://gerrit.libreoffice.org/57549
    Tested-by: Jenkins
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/include/sfx2/linkmgr.hxx b/include/sfx2/linkmgr.hxx
index b1057aef5f1a..128dd47e4462 100644
--- a/include/sfx2/linkmgr.hxx
+++ b/include/sfx2/linkmgr.hxx
@@ -156,9 +156,10 @@ public:
 
     // if the mimetype says graphic/bitmap/gdimetafile then get the
     // graphic from the Any. Return says no errors
-    static bool GetGraphicFromAny( const OUString& rMimeType,
-                                const css::uno::Any & rValue,
-                                Graphic& rGrf );
+    static bool GetGraphicFromAny(const OUString& rMimeType,
+                                  const css::uno::Any & rValue,
+                                  const OUString& rReferer,
+                                  Graphic& rGrf);
 
 private:
                 LinkManager( const LinkManager& ) = delete;
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index 64e89a927f12..b503e06f0cf6 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -40,6 +40,7 @@
 #include <sfx2/request.hxx>
 #include <vcl/dibtools.hxx>
 #include <unotools/charclass.hxx>
+#include <unotools/securityoptions.hxx>
 #include <vcl/GraphicLoader.hxx>
 
 #include "fileobj.hxx"
@@ -497,9 +498,10 @@ SotClipboardFormatId LinkManager::RegisterStatusInfoId()
     return nFormat;
 }
 
-bool LinkManager::GetGraphicFromAny( const OUString& rMimeType,
-                                const css::uno::Any & rValue,
-                                Graphic& rGraphic )
+bool LinkManager::GetGraphicFromAny(const OUString& rMimeType,
+                                    const css::uno::Any & rValue,
+                                    const OUString& rReferer,
+                                    Graphic& rGraphic )
 {
     bool bRet = false;
 
@@ -509,7 +511,8 @@ bool LinkManager::GetGraphicFromAny( const OUString& rMimeType,
     if (rValue.has<OUString>())
     {
         OUString sURL = rValue.get<OUString>();
-        rGraphic = vcl::graphic::loadFromURL(sURL);
+        if (!SvtSecurityOptions().isUntrustedReferer(rReferer))
+            rGraphic = vcl::graphic::loadFromURL(sURL);
         if (!rGraphic)
             rGraphic.SetDefaultType();
         rGraphic.setOriginURL(sURL);
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index d336c9634d42..aa3df15dcd43 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -226,7 +226,7 @@ void SdrGraphicLink::RemoveGraphicUpdater()
         sfx2::LinkManager::GetDisplayNames( this, nullptr, &rGrafObj.aFileName, nullptr, &rGrafObj.aFilterName );
 
         Graphic aGraphic;
-        if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGraphic ))
+        if (sfx2::LinkManager::GetGraphicFromAny(rMimeType, rValue, getReferer(), aGraphic))
         {
             rGrafObj.ImpSetLinkedGraphic(aGraphic);
         }
diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx
index 744eb2720cea..4aa300ee30de 100644
--- a/sw/source/core/docnode/swbaslnk.cxx
+++ b/sw/source/core/docnode/swbaslnk.cxx
@@ -144,7 +144,14 @@ static void lcl_CallModify( SwGrfNode& rGrfNd, SfxPoolItem& rItem )
 
         Graphic aGrf;
 
-        if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGrf ) &&
+        OUString sReferer;
+        SfxObjectShell * sh = pDoc->GetPersist();
+        if (sh != nullptr && sh->HasName())
+        {
+            sReferer = sh->GetMedium()->GetName();
+        }
+
+        if( sfx2::LinkManager::GetGraphicFromAny(rMimeType, rValue, sReferer, aGrf) &&
             ( GraphicType::Default != aGrf.GetType() ||
               GraphicType::Default != rGrfObj.GetType() ) )
         {


More information about the Libreoffice-commits mailing list