summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2023-12-19 19:24:19 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2024-01-11 12:23:27 +0100
commit40c94cff178bd4bef4dc5ce38cc9eb67fe2eb780 (patch)
treeba93e608a9a97879512d17504641dc9072a7c059
parentaaf6ce108e91b1504befe19afcee471e3316ae7a (diff)
lok: send error on access denied in image import 2
followup for commit 64624d225c71229acce4f889d4863d7c29c52658 lok: send error on access denied in image import It shows an error in LOK when we try to insert image from remote host blocked by HostFilter Previously it was showing error in paste case, now do the same also on image insertion. For now disable HandleGraphicFilterError in sd, as it crashes, is synchronous and cannot be easily fixed - dialog sits inside module not linked to sfx2, needs some rework. Change-Id: I3c15ff5621add97ef9d60d4f4c1305dae2909158 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161001 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161774 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--include/sfx2/lokhelper.hxx2
-rw-r--r--sc/source/filter/html/htmlpars.cxx2
-rw-r--r--sc/source/ui/drawfunc/fuins1.cxx11
-rw-r--r--sd/source/ui/func/fuinsert.cxx14
-rw-r--r--sfx2/source/view/lokhelper.cxx4
-rw-r--r--sw/source/filter/html/htmlgrin.cxx2
-rw-r--r--sw/source/uibase/uiview/view2.cxx10
7 files changed, 39 insertions, 6 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index dc9558a31f0f..8ca9ce80da08 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -227,7 +227,7 @@ public:
static VclPtr<vcl::Window> getInPlaceDocWindow(SfxViewShell* pViewShell);
/// Sends Network Access error to LOK
- static void sendNetworkAccessError();
+ static void sendNetworkAccessError(std::string_view rAction);
static void notifyLog(const std::ostringstream& stream);
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index 10d31fc84cd4..43ff3cca2de5 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -1325,7 +1325,7 @@ void ScHTMLLayoutParser::Image( HtmlImportInfo* pInfo )
{
INetURLObject aURL(pImage->aURL);
if (HostFilter::isForbidden(aURL.GetHost()))
- SfxLokHelper::sendNetworkAccessError();
+ SfxLokHelper::sendNetworkAccessError("paste");
}
sal_uInt16 nFormat;
diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
index 72886789b448..9b51a62c5b2a 100644
--- a/sc/source/ui/drawfunc/fuins1.cxx
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -22,6 +22,7 @@
#include <officecfg/Office/Common.hxx>
#include <editeng/sizeitem.hxx>
#include <sal/log.hxx>
+#include <sfx2/lokhelper.hxx>
#include <sfx2/opengrf.hxx>
#include <sfx2/viewfrm.hxx>
#include <svx/svdograf.hxx>
@@ -48,6 +49,9 @@
#include <globstr.hrc>
#include <comphelper/lok.hxx>
+#include <tools/hostfilter.hxx>
+#include <tools/urlobj.hxx>
+
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/media/XPlayer.hpp>
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
@@ -279,6 +283,13 @@ FuInsertGraphic::FuInsertGraphic( ScTabViewShell& rViewSh,
if ( pReqArgs->GetItemState( FN_PARAM_1, true, &pItem ) == SfxItemState::SET )
bAsLink = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ INetURLObject aURL(aFileName);
+ if (INetProtocol::File != aURL.GetProtocol() && HostFilter::isForbidden(aURL.GetHost()))
+ SfxLokHelper::sendNetworkAccessError("insert");
+ }
+
Graphic aGraphic;
ErrCode nError = GraphicFilter::LoadGraphic( aFileName, aFilterName, aGraphic, &GraphicFilter::GetGraphicFilter() );
if ( nError == ERRCODE_NONE )
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index 31b286c822e3..e8409c815b25 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -36,6 +36,7 @@
#include <svl/stritem.hxx>
#include <sfx2/dispatch.hxx>
+#include <sfx2/lokhelper.hxx>
#include <sfx2/msgpool.hxx>
#include <sfx2/msg.hxx>
#include <svtools/insdlg.hxx>
@@ -60,6 +61,9 @@
#include <svx/charthelper.hxx>
#include <svx/svxids.hrc>
+#include <tools/hostfilter.hxx>
+#include <tools/urlobj.hxx>
+
#include <sdresid.hxx>
#include <View.hxx>
#include <sdmod.hxx>
@@ -129,6 +133,13 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq )
if ( pArgs->GetItemState( FN_PARAM_1, true, &pItem ) == SfxItemState::SET )
bAsLink = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ INetURLObject aURL(aFileName);
+ if (INetProtocol::File != aURL.GetProtocol() && HostFilter::isForbidden(aURL.GetHost()))
+ SfxLokHelper::sendNetworkAccessError("insert");
+ }
+
nError = GraphicFilter::LoadGraphic( aFileName, aFilterName, aGraphic, &GraphicFilter::GetGraphicFilter() );
}
else
@@ -188,8 +199,9 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq )
}
}
}
- else
+ else if (!comphelper::LibreOfficeKit::isActive())
{
+ // TODO: enable in LOK, it contains synchronous error window without LOKNotifier
SdGRFFilter::HandleGraphicFilterError( nError, GraphicFilter::GetGraphicFilter().GetLastError() );
}
}
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 647c580610f8..f21457e1b16d 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -1078,13 +1078,13 @@ VclPtr<vcl::Window> SfxLokHelper::getInPlaceDocWindow(SfxViewShell* pViewShell)
return {};
}
-void SfxLokHelper::sendNetworkAccessError()
+void SfxLokHelper::sendNetworkAccessError(std::string_view rAction)
{
tools::JsonWriter aWriter;
aWriter.put("code", static_cast<sal_uInt32>(
ErrCode(ErrCodeArea::Inet, sal_uInt16(ErrCodeClass::Access))));
aWriter.put("kind", "network");
- aWriter.put("cmd", "paste");
+ aWriter.put("cmd", rAction);
SfxViewShell* pViewShell = SfxViewShell::Current();
if (pViewShell)
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index 8304fa3002f3..4b5a0d5e4bd5 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -513,7 +513,7 @@ IMAGE_SETEVENT:
else if (m_sBaseURL.isEmpty() || !aGraphicData.isEmpty())
{
if (comphelper::LibreOfficeKit::isActive() && HostFilter::isForbidden(aGraphicURL.GetHost()))
- SfxLokHelper::sendNetworkAccessError();
+ SfxLokHelper::sendNetworkAccessError("paste");
// sBaseURL is empty if the source is clipboard
// aGraphicData is non-empty for <object data="..."> -> not a linked graphic.
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index 2c7a07449715..1006f5b493ff 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -50,6 +50,7 @@
#include <svx/statusitem.hxx>
#include <svx/viewlayoutitem.hxx>
#include <svx/zoomslideritem.hxx>
+#include <sfx2/lokhelper.hxx>
#include <sfx2/htmlmode.hxx>
#include <vcl/svapp.hxx>
#include <sfx2/app.hxx>
@@ -71,6 +72,7 @@
#include <svl/ptitem.hxx>
#include <sfx2/viewfrm.hxx>
#include <vcl/errinf.hxx>
+#include <tools/hostfilter.hxx>
#include <tools/urlobj.hxx>
#include <svx/svdview.hxx>
#include <swtypes.hxx>
@@ -309,6 +311,14 @@ ErrCode SwView::InsertGraphic( const OUString &rPath, const OUString &rFilter,
{
pFilter = &GraphicFilter::GetGraphicFilter();
}
+
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ INetURLObject aURL(rPath);
+ if (INetProtocol::File != aURL.GetProtocol() && HostFilter::isForbidden(aURL.GetHost()))
+ SfxLokHelper::sendNetworkAccessError("insert");
+ }
+
aResult = GraphicFilter::LoadGraphic( rPath, rFilter, aGraphic, pFilter );
if( ERRCODE_NONE == aResult )