cookie: allow loading cookies for localhost

The added code to avoid loading PSL cookies from files from PR #22500
(c041895, not shipped in a release), calls psl_is_public_suffix(),
returns TRUE also for "localhost" (!).

We now allow cookies again for localhost. Added test 320 to verify.

Reported-by: Athos Ribeiro
Fixes #22645
Closes #22646
This commit is contained in:
Daniel Stenberg 2026-08-23 17:03:06 +02:00
parent 8770c49de4
commit 85c8f6f3a5
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 68 additions and 5 deletions

View file

@ -839,10 +839,14 @@ static bool is_public_suffix(struct Curl_easy *data,
lcase[dlen] = 0;
acceptable = psl_is_cookie_domain_acceptable(psl, lcase, lcookie);
}
else
/* note that this PSL function returns the opposite value than
psl_is_cookie_domain_acceptable() does */
acceptable = !psl_is_public_suffix(psl, lcookie);
else {
/* libpsl says localhost is a PSL, we think not */
acceptable =
curl_strequal(lcookie, "localhost") ||
/* note that this PSL function returns the opposite value than
psl_is_cookie_domain_acceptable() does */
!psl_is_public_suffix(psl, lcookie);
}
Curl_psl_release(data);
}
else