Allow setting <cloak:psl> to "system" to use the system database.

This commit is contained in:
Sadie Powell 2023-01-14 03:44:24 +00:00
parent b3fe433e4c
commit b4dcaaaa62
2 changed files with 11 additions and 3 deletions

View File

@ -595,7 +595,8 @@
# #
# psl - If non-empty then the path to a Mozilla Public Suffix #
# List database to use for finding the visible part of a #
# hostname. This overrides the hostparts (above) field. #
# hostname or "system" to use the system database if one #
# exists. This overrides the hostparts (above) field. #
# Only available if libpsl was installed at build time. #
# #
# IMPORTANT: Changing these details will break all of your existing #
@ -610,7 +611,7 @@
# suffix="ip"
# case="lower"
# hostparts="3"
# psl="/usr/share/publicsuffix/public_suffix_list.dafsa">
# psl="system">
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Codepage module: Allows using a custom 8-bit codepage for nicknames

View File

@ -271,10 +271,17 @@ public:
throw ModuleException(creator, "Your cloak key should be at least " + ConvToStr(minkeylen) + " characters long, at " + tag->source.str());
psl_ctx_t* psl = nullptr;
const std::string psldb = tag->getString("psl");
std::string psldb = tag->getString("psl");
if (!psldb.empty())
{
#ifdef HAS_LIBPSL
if (stdalgo::string::equalsci(psldb, "system"))
{
psldb = psl_dist_filename();
if (psldb.empty())
throw ModuleException(creator, "You specified \"system\" in <cloak:psl> but libpsl was built without a system copy, at " + tag->source.str());
}
psl = psl_load_file(psldb.c_str());
if (!psl)
throw ModuleException(creator, "The database specified in <cloak:psl> (" + psldb + ") does not exist, at " + tag->source.str());