diff options
author | Carlos Garcia Campos <carlos.gcampos@gmail.com> | 2018-06-13 11:42:06 +0000 |
---|---|---|
committer | Carlos Garcia Campos <carlos.gcampos@gmail.com> | 2018-06-13 11:42:06 +0000 |
commit | 9fff4c84c9b3bf75c5c9b300db3a8b4fa09a9645 (patch) | |
tree | 96e65805dfc5294d1f03e365376d2188d6e15adb | |
parent | d20f9a156657f26358a591d35928a868b20c97c5 (diff) | |
parent | f66d47cd5b535157cd8e96646c2300724537ca3d (diff) | |
download | libsoup-9fff4c84c9b3bf75c5c9b300db3a8b4fa09a9645.tar.gz |
Merge branch 'bug-1' into 'master'
Set default cookie path when origin is NULL and value not present in parsed text
Closes #1
See merge request GNOME/libsoup!5
-rw-r--r-- | libsoup/soup-cookie.c | 2 | ||||
-rw-r--r-- | tests/cookies-test.c | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/libsoup/soup-cookie.c b/libsoup/soup-cookie.c index 1d0dde3c..7cea82e5 100644 --- a/libsoup/soup-cookie.c +++ b/libsoup/soup-cookie.c @@ -299,6 +299,8 @@ parse_one_cookie (const char *header, SoupURI *origin) slash - origin->path); } } + } else if (!cookie->path) { + cookie->path = g_strdup ("/"); } return cookie; diff --git a/tests/cookies-test.c b/tests/cookies-test.c index 8735964c..b133f178 100644 --- a/tests/cookies-test.c +++ b/tests/cookies-test.c @@ -219,6 +219,15 @@ do_cookies_parsing_test (void) soup_test_session_abort_unref (session); } +static void +do_cookies_parsing_nopath_nullorigin (void) +{ + SoupCookie *cookie = soup_cookie_parse ("NAME=Value", NULL); + g_assert_nonnull (cookie); + g_assert_cmpstr ("/", ==, soup_cookie_get_path (cookie)); + soup_cookie_free (cookie); +} + int main (int argc, char **argv) { @@ -239,6 +248,7 @@ main (int argc, char **argv) g_test_add_func ("/cookies/accept-policy", do_cookies_accept_policy_test); g_test_add_func ("/cookies/accept-policy-subdomains", do_cookies_subdomain_policy_test); g_test_add_func ("/cookies/parsing", do_cookies_parsing_test); + g_test_add_func ("/cookies/parsing/no-path-null-origin", do_cookies_parsing_nopath_nullorigin); ret = g_test_run (); |