browser(webkit): respect first party url in intercepted set-cookie (soup) (#9320)

This commit is contained in:
Yury Semikhatsky 2021-10-05 12:25:48 -07:00 committed by GitHub
parent 97b6a344ac
commit ec7ae4e96b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -1,2 +1,2 @@
1555 1556
Changed: yurys@chromium.org Mon Oct 4 22:10:59 PDT 2021 Changed: yurys@chromium.org Tue 05 Oct 2021 12:17:40 PM PDT

View File

@ -8601,26 +8601,34 @@ index 4b9491c11543f2b60f12d36e9e6a0cbaae34a72e..e907fc00a2a426384ce1e471847911c9
SocketStreamHandleImpl::~SocketStreamHandleImpl() SocketStreamHandleImpl::~SocketStreamHandleImpl()
diff --git a/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp b/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp diff --git a/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp b/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
index 5b32534e2bcaf1701331e9541013b8a5c38c4d36..efee59ab00e99bc0e5d4374cc0a474461c2c1386 100644 index 5b32534e2bcaf1701331e9541013b8a5c38c4d36..44ca33a774629841214ab3233f8a064557976e78 100644
--- a/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp --- a/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
+++ b/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp +++ b/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
@@ -408,6 +408,22 @@ void NetworkStorageSession::setCookie(const Cookie& cookie) @@ -408,6 +408,30 @@ void NetworkStorageSession::setCookie(const Cookie& cookie)
soup_cookie_jar_add_cookie(cookieStorage(), cookie.toSoupCookie()); soup_cookie_jar_add_cookie(cookieStorage(), cookie.toSoupCookie());
} }
+void NetworkStorageSession::setCookiesFromResponse(const URL&, const URL& url, const String& setCookieValue) +void NetworkStorageSession::setCookiesFromResponse(const URL& firstParty, const URL& url, const String& setCookieValue)
+{ +{
+ auto origin = urlToSoupURI(url); + auto origin = urlToSoupURI(url);
+ if (!origin) + if (!origin)
+ return; + return;
+ +
+ auto firstPartyURI = urlToSoupURI(firstParty);
+ if (!firstPartyURI)
+ return;
+
+ for (auto& cookieString : setCookieValue.split('\n')) { + for (auto& cookieString : setCookieValue.split('\n')) {
+ GUniquePtr<SoupCookie> cookie(soup_cookie_parse(cookieString.utf8().data(), origin.get())); + GUniquePtr<SoupCookie> cookie(soup_cookie_parse(cookieString.utf8().data(), origin.get()));
+ +
+ if (!cookie) + if (!cookie)
+ continue; + continue;
+ +
+ soup_cookie_jar_add_cookie(cookieStorage(), cookie.release()); +#if SOUP_CHECK_VERSION(2, 67, 1)
+ soup_cookie_jar_add_cookie_full(cookieStorage(), cookie.release(), origin.get(), firstPartyURI.get());
+#else
+ soup_cookie_jar_add_cookie_with_first_party(cookieStorage(), firstPartyURI.get(), cookie.release());
+#endif
+ } + }
+} +}
+ +