Add support for psl_latest()

* configure.ac: Add check for psl_latest(),
  remove --with-psl-file
* src/cookies.c (check_domain_match): Use psl_latest() if available
This commit is contained in:
Tim Rühsen 2016-12-11 21:04:40 +01:00
parent 3c796b9a85
commit dcdd618b18
2 changed files with 11 additions and 13 deletions

View File

@ -329,10 +329,9 @@ AS_IF([test "x$with_libpsl" != xno], [
])
])
# Check for custom PSL file
AC_ARG_WITH(psl-file,
AC_HELP_STRING([--with-psl-file=[PATH]], [path to PSL file (plain text or DAFSA)]),
PSL_FILE=$withval AC_DEFINE_UNQUOTED([PSL_FILE], ["$PSL_FILE"], [path to PSL file (plain text or DAFSA)]))
AS_IF([test x"$with_libpsl" = xyes], [
AC_CHECK_FUNCS(psl_latest)
])
AS_IF([test x"$with_zlib" != xno], [
with_zlib=yes
@ -818,7 +817,7 @@ AC_MSG_NOTICE([Summary of build options:
Libs: $LIBS
SSL: $with_ssl
Zlib: $with_zlib
PSL: $with_libpsl $PSL_FILE
PSL: $with_libpsl
Digest: $ENABLE_DIGEST
NTLM: $ENABLE_NTLM
OPIE: $ENABLE_OPIE

View File

@ -538,15 +538,13 @@ check_domain_match (const char *cookie_domain, const char *host)
{
init_psl = 1;
#ifdef PSL_FILE
/* If PSL_FILE is a DAFSA file, loading is very fast */
if ((psl = psl_load_file (PSL_FILE)))
#ifdef HAVE_PSL_LATEST
if ((psl = psl_latest (NULL)))
goto have_psl;
DEBUGP (("\nPSL: %s not found or not readable. "
"Falling back to built-in data.\n", quote (PSL_FILE)));
#endif
DEBUGP (("\nPSL: Failed to load any PSL data. "
"Falling back to insecure heuristics.\n"));
#else
if ((psl = psl_builtin ()) && !psl_builtin_outdated ())
goto have_psl;
@ -564,9 +562,10 @@ check_domain_match (const char *cookie_domain, const char *host)
if (!(psl = psl_builtin ()))
{
DEBUGP (("\nPSL: libpsl not built with a public suffix list. "
"Falling back to simple heuristics.\n"));
"Falling back to insecure heuristics.\n"));
goto no_psl;
}
#endif
}
else if (!psl)
goto no_psl;