Skip to content

Commit fa795ba

Browse files
tKnmoriwebkit-commit-queue
authored andcommitted
[Curl] Implement Cookie Accept Policy.
https://bugs.webkit.org/show_bug.cgi?id=191645 Patch by Takashi Komori <Takashi.Komori@sony.com> on 2019-03-05 Reviewed by Fujii Hironori. Source/WebCore: Make Curl network layer respect to coookie accept policy. This patch fixes tests below on TestRunner, but doesn't fix tests on DumpRenderTree. Tests: http/tests/cookies/only-accept-first-party-cookies.html http/tests/cookies/third-party-cookie-relaxing.html http/tests/security/cookies/third-party-cookie-blocking-redirect.html http/tests/security/cookies/third-party-cookie-blocking-user-action.html http/tests/security/cookies/third-party-cookie-blocking-xslt.xml http/tests/security/cookies/third-party-cookie-blocking.html * platform/network/curl/CookieJarCurl.cpp: (WebCore::cookiesForSession): (WebCore::CookieJarCurl::setCookiesFromDOM const): (WebCore::CookieJarCurl::setCookiesFromHTTPResponse const): (WebCore::CookieJarCurl::setCookieAcceptPolicy const): (WebCore::CookieJarCurl::cookieAcceptPolicy const): (WebCore::CookieJarCurl::getRawCookies const): * platform/network/curl/CookieJarCurl.h: * platform/network/curl/CookieJarDB.cpp: (WebCore::CookieJarDB::openDatabase): (WebCore::CookieJarDB::isEnabled const): (WebCore::CookieJarDB::checkCookieAcceptPolicy): (WebCore::CookieJarDB::hasCookies): (WebCore::CookieJarDB::searchCookies): (WebCore::CookieJarDB::canAcceptCookie): (WebCore::CookieJarDB::setCookie): (WebCore::CookieJarDB::setEnabled): Deleted. * platform/network/curl/CookieJarDB.h: (WebCore::CookieJarDB::setAcceptPolicy): (WebCore::CookieJarDB::acceptPolicy const): * platform/network/curl/CookieUtil.cpp: (WebCore::CookieUtil::parseCookieAttributes): (WebCore::CookieUtil::parseCookieHeader): * platform/network/curl/CurlResourceHandleDelegate.cpp: (WebCore::handleCookieHeaders): (WebCore::CurlResourceHandleDelegate::curlDidReceiveResponse): Source/WebKit: * NetworkProcess/Cookies/curl/WebCookieManagerCurl.cpp: (WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy): (WebKit::WebCookieManager::platformGetHTTPCookieAcceptPolicy): * NetworkProcess/curl/NetworkDataTaskCurl.cpp: (WebKit::NetworkDataTaskCurl::curlDidReceiveResponse): (WebKit::NetworkDataTaskCurl::handleCookieHeaders): * NetworkProcess/curl/NetworkDataTaskCurl.h: Tools: * TestWebKitAPI/Tests/WebCore/curl/Cookies.cpp: (TestWebKitAPI::Curl::TEST_F): LayoutTests: * platform/wincairo-wk1/TestExpectations: * platform/wincairo/TestExpectations: Canonical link: https://commits.webkit.org/209684@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242517 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 57001ea commit fa795ba

16 files changed

Lines changed: 259 additions & 81 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2019-03-05 Takashi Komori <Takashi.Komori@sony.com>
2+
3+
[Curl] Implement Cookie Accept Policy.
4+
https://bugs.webkit.org/show_bug.cgi?id=191645
5+
6+
Reviewed by Fujii Hironori.
7+
8+
* platform/wincairo-wk1/TestExpectations:
9+
* platform/wincairo/TestExpectations:
10+
111
2019-03-05 Said Abou-Hallawa <sabouhallawa@apple.com>
212

313
SVGPathSegList.insertItemBefore() should fail if the newItem belongs to an animating animPathSegList

LayoutTests/platform/wincairo-wk1/TestExpectations

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,13 @@
1212

1313
# Failures on WebKit Legacy
1414

15+
# Cookie policy only supported in WK2.
16+
http/tests/cookies/only-accept-first-party-cookies.html [ Skip ]
17+
http/tests/cookies/third-party-cookie-relaxing.html [ Skip ]
18+
http/tests/security/cookies/third-party-cookie-blocking.html [ Skip ]
19+
http/tests/security/cookies/third-party-cookie-blocking-redirect.html [ Skip ]
20+
http/tests/security/cookies/third-party-cookie-blocking-user-action.html [ Skip ]
21+
http/tests/security/cookies/third-party-cookie-blocking-xslt.xml [ Skip ]
22+
1523
# There is not NetworkProcess in WK1, so it can't crash.
1624
http/tests/websocket/tests/hybi/network-process-crash-error.html [ Skip ]

LayoutTests/platform/wincairo/TestExpectations

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,14 +862,14 @@ http/tests/cookies/double-quoted-value-with-semi-colon.html [ Failure ]
862862
http/tests/cookies/http-get-cookie-set-in-js.html [ Pass Failure ]
863863
http/tests/cookies/multiple-cookies.html [ Pass Failure ]
864864
http/tests/cookies/multiple-redirect-and-set-cookie.php [ Pass Failure ]
865+
http/tests/cookies/only-accept-first-party-cookies.html [ Pass ]
865866
http/tests/cookies/private-cookie-storage.html [ Skip ]
866867
http/tests/cookies/same-site [ Skip ]
867868
http/tests/cookies/set-cookie-on-redirect.html [ Pass Failure ]
868869
http/tests/cookies/simple-cookies-expired.html [ Pass Failure ]
869870
http/tests/cookies/simple-cookies-max-age.html [ Pass Failure ]
870871
http/tests/cookies/single-quoted-value.html [ Pass Failure ]
871872
http/tests/cookies/sync-xhr-set-cookie-invalidates-cache.html [ Pass Failure ]
872-
http/tests/cookies/third-party-cookie-relaxing.html [ Failure ]
873873

874874
[ Debug ] http/tests/cookies/js-get-and-set-http-only-cookie.html [ Skip ]
875875

@@ -939,6 +939,10 @@ http/tests/quicklook [ Skip ]
939939

940940
http/tests/security [ Skip ]
941941
http/tests/security/401-logout/401-logout.php [ Pass ]
942+
http/tests/security/cookies/third-party-cookie-blocking.html [ Pass ]
943+
http/tests/security/cookies/third-party-cookie-blocking-redirect.html [ Pass ]
944+
http/tests/security/cookies/third-party-cookie-blocking-user-action.html [ Pass ]
945+
http/tests/security/cookies/third-party-cookie-blocking-xslt.xml [ Pass ]
942946

943947
http/tests/ssl [ Skip ]
944948

Source/WebCore/ChangeLog

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
2019-03-05 Takashi Komori <Takashi.Komori@sony.com>
2+
3+
[Curl] Implement Cookie Accept Policy.
4+
https://bugs.webkit.org/show_bug.cgi?id=191645
5+
6+
Reviewed by Fujii Hironori.
7+
8+
Make Curl network layer respect to coookie accept policy.
9+
This patch fixes tests below on TestRunner, but doesn't fix tests on DumpRenderTree.
10+
11+
Tests: http/tests/cookies/only-accept-first-party-cookies.html
12+
http/tests/cookies/third-party-cookie-relaxing.html
13+
http/tests/security/cookies/third-party-cookie-blocking-redirect.html
14+
http/tests/security/cookies/third-party-cookie-blocking-user-action.html
15+
http/tests/security/cookies/third-party-cookie-blocking-xslt.xml
16+
http/tests/security/cookies/third-party-cookie-blocking.html
17+
18+
* platform/network/curl/CookieJarCurl.cpp:
19+
(WebCore::cookiesForSession):
20+
(WebCore::CookieJarCurl::setCookiesFromDOM const):
21+
(WebCore::CookieJarCurl::setCookiesFromHTTPResponse const):
22+
(WebCore::CookieJarCurl::setCookieAcceptPolicy const):
23+
(WebCore::CookieJarCurl::cookieAcceptPolicy const):
24+
(WebCore::CookieJarCurl::getRawCookies const):
25+
* platform/network/curl/CookieJarCurl.h:
26+
* platform/network/curl/CookieJarDB.cpp:
27+
(WebCore::CookieJarDB::openDatabase):
28+
(WebCore::CookieJarDB::isEnabled const):
29+
(WebCore::CookieJarDB::checkCookieAcceptPolicy):
30+
(WebCore::CookieJarDB::hasCookies):
31+
(WebCore::CookieJarDB::searchCookies):
32+
(WebCore::CookieJarDB::canAcceptCookie):
33+
(WebCore::CookieJarDB::setCookie):
34+
(WebCore::CookieJarDB::setEnabled): Deleted.
35+
* platform/network/curl/CookieJarDB.h:
36+
(WebCore::CookieJarDB::setAcceptPolicy):
37+
(WebCore::CookieJarDB::acceptPolicy const):
38+
* platform/network/curl/CookieUtil.cpp:
39+
(WebCore::CookieUtil::parseCookieAttributes):
40+
(WebCore::CookieUtil::parseCookieHeader):
41+
* platform/network/curl/CurlResourceHandleDelegate.cpp:
42+
(WebCore::handleCookieHeaders):
43+
(WebCore::CurlResourceHandleDelegate::curlDidReceiveResponse):
44+
145
2019-03-05 Zalan Bujtas <zalan@apple.com>
246

347
[ContentChangeObserver] Assert on if notify content change is allowed

Source/WebCore/platform/network/curl/CookieJarCurl.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939

4040
namespace WebCore {
4141

42-
static String cookiesForSession(const NetworkStorageSession& session, const URL&, const URL& url, bool forHTTPHeader)
42+
static String cookiesForSession(const NetworkStorageSession& session, const URL& firstParty, const URL& url, bool forHTTPHeader)
4343
{
4444
StringBuilder cookies;
4545

4646
CookieJarDB& cookieJarDB = session.cookieDatabase();
4747
auto searchHTTPOnly = (forHTTPHeader ? WTF::nullopt : Optional<bool> {false});
4848
auto secure = url.protocolIs("https") ? WTF::nullopt : Optional<bool> {false};
4949

50-
if (auto result = cookieJarDB.searchCookies(url.string(), searchHTTPOnly, secure, WTF::nullopt)) {
50+
if (auto result = cookieJarDB.searchCookies(firstParty, url, searchHTTPOnly, secure, WTF::nullopt)) {
5151
for (auto& cookie : *result) {
5252
if (!cookies.isEmpty())
5353
cookies.append("; ");
@@ -63,16 +63,15 @@ void CookieJarCurl::setCookiesFromDOM(const NetworkStorageSession& session, cons
6363
{
6464
UNUSED_PARAM(frameID);
6565
UNUSED_PARAM(pageID);
66-
UNUSED_PARAM(firstParty);
6766

6867
CookieJarDB& cookieJarDB = session.cookieDatabase();
69-
cookieJarDB.setCookie(url.string(), value, CookieJarDB::Source::Script);
68+
cookieJarDB.setCookie(firstParty, url, value, CookieJarDB::Source::Script);
7069
}
7170

72-
void CookieJarCurl::setCookiesFromHTTPResponse(const NetworkStorageSession& session, const URL& url, const String& value) const
71+
void CookieJarCurl::setCookiesFromHTTPResponse(const NetworkStorageSession& session, const URL& firstParty, const URL& url, const String& value) const
7372
{
7473
CookieJarDB& cookieJarDB = session.cookieDatabase();
75-
cookieJarDB.setCookie(url.string(), value, CookieJarDB::Source::Network);
74+
cookieJarDB.setCookie(firstParty, url, value, CookieJarDB::Source::Network);
7675
}
7776

7877
std::pair<String, bool> CookieJarCurl::cookiesForDOM(const NetworkStorageSession& session, const URL& firstParty, const SameSiteInfo&, const URL& url, Optional<uint64_t> frameID, Optional<uint64_t> pageID, IncludeSecureCookies) const
@@ -98,6 +97,17 @@ std::pair<String, bool> CookieJarCurl::cookieRequestHeaderFieldValue(const Netwo
9897
return cookieRequestHeaderFieldValue(session, headerFieldProxy.firstParty, headerFieldProxy.sameSiteInfo, headerFieldProxy.url, headerFieldProxy.frameID, headerFieldProxy.pageID, headerFieldProxy.includeSecureCookies);
9998
}
10099

100+
void CookieJarCurl::setCookieAcceptPolicy(const NetworkStorageSession& session, CookieAcceptPolicy policy) const
101+
{
102+
auto& cookieJarDB = session.cookieDatabase();
103+
cookieJarDB.setAcceptPolicy(policy);
104+
}
105+
106+
CookieAcceptPolicy CookieJarCurl::cookieAcceptPolicy(const NetworkStorageSession& session) const
107+
{
108+
return session.cookieDatabase().acceptPolicy();
109+
}
110+
101111
bool CookieJarCurl::cookiesEnabled(const NetworkStorageSession& session) const
102112
{
103113
return session.cookieDatabase().isEnabled();
@@ -109,7 +119,7 @@ bool CookieJarCurl::getRawCookies(const NetworkStorageSession& session, const UR
109119
UNUSED_PARAM(pageID);
110120

111121
CookieJarDB& cookieJarDB = session.cookieDatabase();
112-
if (auto cookies = cookieJarDB.searchCookies(firstParty.string(), WTF::nullopt, WTF::nullopt, WTF::nullopt)) {
122+
if (auto cookies = cookieJarDB.searchCookies(firstParty, firstParty, WTF::nullopt, WTF::nullopt, WTF::nullopt)) {
113123
rawCookies = WTFMove(*cookies);
114124
return true;
115125
}

Source/WebCore/platform/network/curl/CookieJarCurl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@ enum class IncludeSecureCookies : bool;
3737
struct Cookie;
3838
struct CookieRequestHeaderFieldProxy;
3939
struct SameSiteInfo;
40+
enum class CookieAcceptPolicy;
4041

4142
class CookieJarCurl {
4243
public:
4344
std::pair<String, bool> cookiesForDOM(const NetworkStorageSession&, const URL& firstParty, const SameSiteInfo&, const URL&, Optional<uint64_t> frameID, Optional<uint64_t> pageID, IncludeSecureCookies) const;
4445
void setCookiesFromDOM(const NetworkStorageSession&, const URL& firstParty, const SameSiteInfo&, const URL&, Optional<uint64_t> frameID, Optional<uint64_t> pageID, const String&) const;
45-
void setCookiesFromHTTPResponse(const NetworkStorageSession&, const URL&, const String&) const;
46+
void setCookiesFromHTTPResponse(const NetworkStorageSession&, const URL& firstParty, const URL&, const String&) const;
47+
void setCookieAcceptPolicy(const NetworkStorageSession&, CookieAcceptPolicy) const;
48+
CookieAcceptPolicy cookieAcceptPolicy(const NetworkStorageSession&) const;
4649
bool cookiesEnabled(const NetworkStorageSession&) const;
4750
std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession&, const URL& firstParty, const SameSiteInfo&, const URL&, Optional<uint64_t> frameID, Optional<uint64_t> pageID, IncludeSecureCookies) const;
4851
std::pair<String, bool> cookieRequestHeaderFieldValue(const NetworkStorageSession&, const CookieRequestHeaderFieldProxy&) const;

0 commit comments

Comments
 (0)