Title: [227964] trunk/Source/WebCore
Revision
227964
Author
[email protected]
Date
2018-02-01 07:53:42 -0800 (Thu, 01 Feb 2018)

Log Message

[SOUP] Ensure domain is valid when converting a WebCore Cookie to Soup
https://bugs.webkit.org/show_bug.cgi?id=182328

Reviewed by Michael Catanzaro.

soup_cookie_parse() adds the initial '.' to the domain if missing before creating the SoupCookie, but
soup_cookie_new() allows for domain to be a hostname that needs to match exactly. When converting a WebCore
Cookie into a SoupCookie we always want the domain to be considered as such and not as a hostname, so we need to
prepend the '.' if missing.

Fixes: imported/w3c/webdriver/tests/cookies/add_cookie.py::test_add_domain_cookie

* platform/network/soup/CookieSoup.cpp:
(WebCore::Cookie::toSoupCookie const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (227963 => 227964)


--- trunk/Source/WebCore/ChangeLog	2018-02-01 15:52:33 UTC (rev 227963)
+++ trunk/Source/WebCore/ChangeLog	2018-02-01 15:53:42 UTC (rev 227964)
@@ -1,3 +1,20 @@
+2018-02-01  Carlos Garcia Campos  <[email protected]>
+
+        [SOUP] Ensure domain is valid when converting a WebCore Cookie to Soup
+        https://bugs.webkit.org/show_bug.cgi?id=182328
+
+        Reviewed by Michael Catanzaro.
+
+        soup_cookie_parse() adds the initial '.' to the domain if missing before creating the SoupCookie, but
+        soup_cookie_new() allows for domain to be a hostname that needs to match exactly. When converting a WebCore
+        Cookie into a SoupCookie we always want the domain to be considered as such and not as a hostname, so we need to
+        prepend the '.' if missing.
+
+        Fixes: imported/w3c/webdriver/tests/cookies/add_cookie.py::test_add_domain_cookie
+
+        * platform/network/soup/CookieSoup.cpp:
+        (WebCore::Cookie::toSoupCookie const):
+
 2018-02-01  Zalan Bujtas  <[email protected]>
 
         [RenderTreeBuilder] Move RenderTableRow::collapseAndDestroyAnonymousSiblingRows to RenderTreeBuilder

Modified: trunk/Source/WebCore/platform/network/soup/CookieSoup.cpp (227963 => 227964)


--- trunk/Source/WebCore/platform/network/soup/CookieSoup.cpp	2018-02-01 15:52:33 UTC (rev 227963)
+++ trunk/Source/WebCore/platform/network/soup/CookieSoup.cpp	2018-02-01 15:53:42 UTC (rev 227964)
@@ -60,8 +60,13 @@
     if (name.isNull() || value.isNull() || domain.isNull() || path.isNull())
         return nullptr;
 
+    // soup_cookie_new() will handle the given domain as a hostname if it doesn't start with '.'.
+    auto cookieDomain = domain.utf8();
+    if (cookieDomain.length() && !g_hostname_is_ip_address(cookieDomain.data()) && cookieDomain.data()[0] != '.')
+        cookieDomain = makeString('.', domain).utf8();
+
     SoupCookie* soupCookie = soup_cookie_new(name.utf8().data(), value.utf8().data(),
-        domain.utf8().data(), path.utf8().data(), -1);
+        cookieDomain.data(), path.utf8().data(), -1);
 
     soup_cookie_set_http_only(soupCookie, httpOnly);
     soup_cookie_set_secure(soupCookie, secure);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to