Changeset 227964 in webkit


Ignore:
Timestamp:
Feb 1, 2018 7:53:42 AM (6 years ago)
Author:
Carlos Garcia Campos
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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r227963 r227964  
     12018-02-01  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [SOUP] Ensure domain is valid when converting a WebCore Cookie to Soup
     4        https://bugs.webkit.org/show_bug.cgi?id=182328
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        soup_cookie_parse() adds the initial '.' to the domain if missing before creating the SoupCookie, but
     9        soup_cookie_new() allows for domain to be a hostname that needs to match exactly. When converting a WebCore
     10        Cookie into a SoupCookie we always want the domain to be considered as such and not as a hostname, so we need to
     11        prepend the '.' if missing.
     12
     13        Fixes: imported/w3c/webdriver/tests/cookies/add_cookie.py::test_add_domain_cookie
     14
     15        * platform/network/soup/CookieSoup.cpp:
     16        (WebCore::Cookie::toSoupCookie const):
     17
    1182018-02-01  Zalan Bujtas  <zalan@apple.com>
    219
  • trunk/Source/WebCore/platform/network/soup/CookieSoup.cpp

    r225054 r227964  
    6161        return nullptr;
    6262
     63    // soup_cookie_new() will handle the given domain as a hostname if it doesn't start with '.'.
     64    auto cookieDomain = domain.utf8();
     65    if (cookieDomain.length() && !g_hostname_is_ip_address(cookieDomain.data()) && cookieDomain.data()[0] != '.')
     66        cookieDomain = makeString('.', domain).utf8();
     67
    6368    SoupCookie* soupCookie = soup_cookie_new(name.utf8().data(), value.utf8().data(),
    64         domain.utf8().data(), path.utf8().data(), -1);
     69        cookieDomain.data(), path.utf8().data(), -1);
    6570
    6671    soup_cookie_set_http_only(soupCookie, httpOnly);
Note: See TracChangeset for help on using the changeset viewer.