tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / tools / source / inet / hostfilter.cxx
blobe13e3d66cab6efb9b5673ac8d8d600436087378c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <tools/hostfilter.hxx>
11 #include <regex>
13 static std::regex g_AllowedHostsRegex("");
14 static OUString g_ExceptVerifyHost;
15 static bool g_AllowedHostsSet = false;
17 void HostFilter::setAllowedHostsRegex(const char* sAllowedRegex)
19 g_AllowedHostsSet = sAllowedRegex && sAllowedRegex[0] != '\0';
20 if (g_AllowedHostsSet)
21 g_AllowedHostsRegex = sAllowedRegex;
24 bool HostFilter::isForbidden(const OUString& rHost)
26 if (!g_AllowedHostsSet)
27 return false;
29 return !std::regex_match(rHost.toUtf8().getStr(), g_AllowedHostsRegex);
32 void HostFilter::setExemptVerifyHost(const OUString& rExemptVerifyHost)
34 g_ExceptVerifyHost = rExemptVerifyHost;
37 bool HostFilter::isExemptVerifyHost(const std::u16string_view rHost)
39 return rHost == g_ExceptVerifyHost;
42 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */