mirror of
https://github.com/curl/curl.git
synced 2026-08-24 21:43:32 +03:00
cookies: Add support for Mozilla's Publix Suffix List
Use libpsl to check the domain value of Set-Cookie headers (and cookie jar entries) for not being a Publix Suffix. The configure script checks for "libpsl" by default. Disable the check with --without-libpsl. Ref: https://publicsuffix.org/ Ref: https://github.com/publicsuffix/list Ref: https://github.com/rockdaboot/libpsl
This commit is contained in:
parent
684816cd9b
commit
e77b5b7453
7 changed files with 134 additions and 1 deletions
21
lib/cookie.c
21
lib/cookie.c
|
|
@ -84,6 +84,10 @@ Example set of cookies:
|
|||
|
||||
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
|
||||
|
||||
#ifdef USE_LIBPSL
|
||||
# include <libpsl.h>
|
||||
#endif
|
||||
|
||||
#include "curl_printf.h"
|
||||
#include "urldata.h"
|
||||
#include "cookie.h"
|
||||
|
|
@ -379,6 +383,10 @@ Curl_cookie_add(struct SessionHandle *data,
|
|||
bool replace_old = FALSE;
|
||||
bool badcookie = FALSE; /* cookies are good by default. mmmmm yummy */
|
||||
|
||||
#ifdef USE_LIBPSL
|
||||
const psl_ctx_t *psl;
|
||||
#endif
|
||||
|
||||
#ifdef CURL_DISABLE_VERBOSE_STRINGS
|
||||
(void)data;
|
||||
#endif
|
||||
|
|
@ -777,6 +785,19 @@ Curl_cookie_add(struct SessionHandle *data,
|
|||
/* at first, remove expired cookies */
|
||||
remove_expired(c);
|
||||
|
||||
#ifdef USE_LIBPSL
|
||||
/* Check if the domain is a Public Suffix and if yes, ignore the cookie.
|
||||
This needs a libpsl compiled with builtin data. */
|
||||
if(co->domain && !isip(co->domain) && (psl = psl_builtin()) != NULL) {
|
||||
if(psl_is_public_suffix(psl, co->domain)) {
|
||||
infof(data, "cookie '%s' dropped, domain '%s' is a public suffix\n",
|
||||
co->name, co->domain);
|
||||
freecookie(co);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
clist = c->cookies;
|
||||
replace_old = FALSE;
|
||||
while(clist) {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@
|
|||
#include <stringprep.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_LIBPSL
|
||||
#include <libpsl.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
|
|
@ -100,6 +104,11 @@ char *curl_version(void)
|
|||
ptr += len;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_LIBPSL
|
||||
len = snprintf(ptr, left, " libpsl/%s", psl_get_version());
|
||||
left -= len;
|
||||
ptr += len;
|
||||
#endif
|
||||
#ifdef USE_WIN32_IDN
|
||||
len = snprintf(ptr, left, " WinIDN");
|
||||
left -= len;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue