summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2023-12-01 08:35:51 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2024-01-09 07:49:11 +0100
commitcf767af8de12157155eaf525ee845b196826aeb9 (patch)
treeabde88ae74a25d7f107e7687f6ead128be3e4812 /tools
parentfb7b0b944741e4efae8d92a6e305036aff906c7a (diff)
lok: external data source list
Make possible to filter allowed data sources. It is used for WebDAV curl, WEBSERVICE function, cell external references. Change-Id: Ifc82af31ff1123b5656a21e6a27624fb1616db39 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160196 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/+/161772 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/Library_tl.mk1
-rw-r--r--tools/source/inet/hostfilter.cxx31
2 files changed, 32 insertions, 0 deletions
diff --git a/tools/Library_tl.mk b/tools/Library_tl.mk
index 8269e6ae98bf..99176a7c0902 100644
--- a/tools/Library_tl.mk
+++ b/tools/Library_tl.mk
@@ -67,6 +67,7 @@ $(eval $(call gb_Library_add_exception_objects,tl,\
tools/source/inet/inetmime \
tools/source/inet/inetmsg \
tools/source/inet/inetstrm \
+ tools/source/inet/hostfilter \
tools/source/memtools/multisel \
tools/source/misc/cpuid \
tools/source/misc/extendapplicationenvironment \
diff --git a/tools/source/inet/hostfilter.cxx b/tools/source/inet/hostfilter.cxx
new file mode 100644
index 000000000000..5bc63d42cfb7
--- /dev/null
+++ b/tools/source/inet/hostfilter.cxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <tools/hostfilter.hxx>
+#include <regex>
+
+static std::regex g_AllowedHostsRegex("");
+static bool g_AllowedHostsSet = false;
+
+void HostFilter::setAllowedHostsRegex(const char* sAllowedRegex)
+{
+ g_AllowedHostsSet = sAllowedRegex && sAllowedRegex[0] != '\0';
+ if (g_AllowedHostsSet)
+ g_AllowedHostsRegex = sAllowedRegex;
+}
+
+bool HostFilter::isForbidden(const OUString& rHost)
+{
+ if (!g_AllowedHostsSet)
+ return false;
+
+ return !std::regex_match(rHost.toUtf8().getStr(), g_AllowedHostsRegex);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */