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>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 )
|
||||
|
||||
Reference in New Issue
Block a user