summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiwei Li <siwei.li@live.com>2023-01-17 16:18:33 -0800
committerPatrick Griffis <pgriffis@igalia.com>2023-01-19 14:30:23 -0600
commit771bf193b67695a86a44c36ed7e20ae4bee66bda (patch)
treebba2c6f3dc0ac910945ea661b10c4d16bce2c09f
parentaadd3ca2c5c95fbdd0b90666d7919bc60511aa3a (diff)
downloadlibsoup-771bf193b67695a86a44c36ed7e20ae4bee66bda.tar.gz
cookies: Only consider space and tab as whitespace
The cookies spec defines whitespace as that. Previously we handled everything `isspace()` considered whitespace such as newlines which is incorrect.
-rw-r--r--libsoup/cookies/soup-cookie.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/libsoup/cookies/soup-cookie.c b/libsoup/cookies/soup-cookie.c
index 814d2b02..7c41b1dd 100644
--- a/libsoup/cookies/soup-cookie.c
+++ b/libsoup/cookies/soup-cookie.c
@@ -108,27 +108,25 @@ soup_cookie_domain_matches (SoupCookie *cookie, const char *host)
return soup_host_matches_host (cookie->domain, host);
}
-#define IS_CNTRL(chr) ( g_ascii_iscntrl (chr) && chr != 0x09 )
+static inline gboolean
+is_white_space (char c)
+{
+ return (c == ' ' || c == '\t');
+}
static inline const char *
skip_lws (const char *s)
{
- while (g_ascii_isspace (*s)) {
- if (IS_CNTRL (*s))
- return s;
+ while (is_white_space (*s))
s++;
- }
return s;
}
static inline const char *
unskip_lws (const char *s, const char *start)
{
- while (s > start && g_ascii_isspace (*(s - 1))) {
+ while (s > start && is_white_space (*(s - 1)))
s--;
- if (IS_CNTRL (*s))
- return s;
- }
return s;
}