From: Dan Winship Date: Thu, 17 Dec 2009 19:47:30 +0000 (+0100) Subject: SoupCookie: more fixes to path handling X-Git-Tag: LIBSOUP_2_29_5~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aba689f9b10b034d398847d4d45aa026213db1eb;p=platform%2Fupstream%2Flibsoup.git SoupCookie: more fixes to path handling --- diff --git a/libsoup/soup-cookie.c b/libsoup/soup-cookie.c index c9d28b8..536b387 100644 --- a/libsoup/soup-cookie.c +++ b/libsoup/soup-cookie.c @@ -306,11 +306,12 @@ parse_one_cookie (const char *header, SoupURI *origin) if (!cookie->path) { char *slash; - cookie->path = g_strdup (origin->path); - if (strcmp (cookie->path, "/") != 0) { - slash = strrchr (cookie->path, '/'); - if (slash) - *slash = '\0'; + slash = strrchr (origin->path, '/'); + if (!slash || slash == origin->path) + cookie->path = g_strdup ("/"); + else { + cookie->path = g_strndup (origin->path, + slash - origin->path); } } } @@ -922,15 +923,11 @@ soup_cookie_applies_to_uri (SoupCookie *cookie, SoupURI *uri) /* uri->path is required to be non-NULL */ g_return_val_if_fail (uri->path != NULL, FALSE); - /* The spec claims "/foo would match /foobar", but fortunately - * no one is really that crazy. - */ plen = strlen (cookie->path); - if (cookie->path[plen - 1] == '/') - plen--; if (strncmp (cookie->path, uri->path, plen) != 0) return FALSE; - if (uri->path[plen] && uri->path[plen] != '/') + if (cookie->path[plen - 1] != '/' && + uri->path[plen] && uri->path[plen] != '/') return FALSE; return TRUE;