kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone
91334d
From daa1750bd6944f5202ccb7bc41c57a3f32be766e Mon Sep 17 00:00:00 2001
91334d
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
91334d
Date: Tue, 1 May 2018 12:57:02 +0100
91334d
Subject: [PATCH] set Referer on link mediadescriptor
91334d
91334d
to allow determining if the source document is from a trusted/untrusted
91334d
location
91334d
91334d
Change-Id: I780568652d2ef0cc8543c27ba26289277b5d9d0c
91334d
Reviewed-on: https://gerrit.libreoffice.org/53693
91334d
Tested-by: Jenkins <ci@libreoffice.org>
91334d
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
91334d
---
91334d
 sw/source/filter/xml/xmltexti.cxx | 13 +++++++++----
91334d
 1 file changed, 9 insertions(+), 4 deletions(-)
91334d
91334d
diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx
91334d
index 06a6bbe..83d7734 100644
91334d
--- a/sw/source/filter/xml/xmltexti.cxx
91334d
+++ b/sw/source/filter/xml/xmltexti.cxx
91334d
@@ -575,17 +575,22 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOOoLink(
91334d
 
91334d
         uno::Sequence< beans::PropertyValue > aMediaDescriptor( 1 );
91334d
         aMediaDescriptor[0].Name = "URL";
91334d
-        aMediaDescriptor[0].Value <<= OUString( aURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
91334d
-        if ( pDoc->GetDocShell() && pDoc->GetDocShell()->GetMedium() )
91334d
+        aMediaDescriptor[0].Value <<= aURLObj.GetMainURL( INetURLObject::NO_DECODE );
91334d
+
91334d
+        if (SfxMedium* pMedium = pDoc->GetDocShell() ? pDoc->GetDocShell()->GetMedium() : nullptr)
91334d
         {
91334d
-            uno::Reference< task::XInteractionHandler > xInteraction =
91334d
-                                        pDoc->GetDocShell()->GetMedium()->GetInteractionHandler();
91334d
+            uno::Reference< task::XInteractionHandler > xInteraction = pMedium->GetInteractionHandler();
91334d
             if ( xInteraction.is() )
91334d
             {
91334d
                 aMediaDescriptor.realloc( 2 );
91334d
                 aMediaDescriptor[1].Name = "InteractionHandler";
91334d
                 aMediaDescriptor[1].Value <<= xInteraction;
91334d
             }
91334d
+
91334d
+            const auto nLen = aMediaDescriptor.getLength() + 1;
91334d
+            aMediaDescriptor.realloc(nLen);
91334d
+            aMediaDescriptor[nLen - 1].Name = "Referer";
91334d
+            aMediaDescriptor[nLen - 1].Value <<= pMedium->GetName();
91334d
         }
91334d
 
91334d
         uno::Reference < embed::XEmbeddedObject > xObj(
91334d
-- 
91334d
2.14.3
91334d