WebKit Bugzilla
Attachment 371606 Details for
Bug 198635
: [WKHTTPCookieStore getAllCookies:] may return duplicate cookies
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198635-20190607134207.patch (text/plain), 8.16 KB, created by
Sihui Liu
on 2019-06-07 13:42:07 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sihui Liu
Created:
2019-06-07 13:42:07 PDT
Size:
8.16 KB
patch
obsolete
>Subversion Revision: 246203 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index af9788cdfc6cc4d724952e7d81ab9a7f218133e2..18e01f099d70f3f9bd9bb9effba240b77ca82055 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,33 @@ >+2019-06-07 Sihui Liu <sihui_liu@apple.com> >+ >+ [WKHTTPCookieStore getAllCookies:] may return duplicate cookies >+ https://bugs.webkit.org/show_bug.cgi?id=198635 >+ <rdar://problem/46010232> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: WebKit.WKHTTPCookieStoreWithoutProcessPoolDuplicates >+ >+ * platform/Cookie.h: >+ (WebCore::Cookie::isKeyEqual const): >+ * platform/network/cocoa/CookieCocoa.mm: >+ (WebCore::Cookie::operator== const): >+ >+2019-06-07 Sihui Liu <sihui_liu@apple.com> >+ >+ [WKHTTPCookieStore getAllCookies:] may return duplicate cookies >+ https://bugs.webkit.org/show_bug.cgi?id=198635 >+ <rdar://problem/46010232> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: WebKit.WKHTTPCookieStoreWithoutProcessPoolDuplicates >+ >+ * platform/Cookie.h: >+ (WebCore::Cookie::isKeyEqual const): >+ * platform/network/cocoa/CookieCocoa.mm: >+ (WebCore::Cookie::operator== const): >+ > 2019-06-07 Joonghun Park <jh718.park@samsung.com> > > Unreviewed. Use const TabSize& instead of TabSize to avoid unnecessary copy. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index afdecf531d9035643e5cb1a6ce031521c3172bb9..ccc358c56565633606f6b8b2d92f8775d35d4c49 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,21 @@ >+2019-06-07 Sihui Liu <sihui_liu@apple.com> >+ >+ [WKHTTPCookieStore getAllCookies:] may return duplicate cookies >+ https://bugs.webkit.org/show_bug.cgi?id=198635 >+ <rdar://problem/46010232> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When there is no process pool, we store cookies set in memory with HashSet m_pendingCookies of WebsiteDataStore. >+ >+ HashSet does not contain duplicate Cookies that are completely identical, but it may contain Cookies that have >+ all the other properties identical other than value. This is not correct because Cookies with same name, domain >+ and path should be treated as the same cookie. When a cookie is set via API, we should either insert the >+ cookie into m_pendingCookies if the cookie does not exist, or update the cookie value if it already exists. >+ >+ * UIProcess/WebsiteData/WebsiteDataStore.cpp: >+ (WebKit::WebsiteDataStore::addPendingCookie): >+ > 2019-06-07 Andy Estes <aestes@apple.com> > > process-swap-on-navigation error when loading blocked website on iOS 12.2 only. >diff --git a/Source/WebCore/platform/Cookie.h b/Source/WebCore/platform/Cookie.h >index 1e05fcb362724c27fdabd8e2fb509490388c8dbe..d3236f5ec87e88128102e08af199269e74e19107 100644 >--- a/Source/WebCore/platform/Cookie.h >+++ b/Source/WebCore/platform/Cookie.h >@@ -76,6 +76,13 @@ struct Cookie { > && commentURL.isNull(); > } > >+ bool isKeyEqual(const Cookie& otherCookie) const >+ { >+ return name == otherCookie.name >+ && domain == otherCookie.domain >+ && path == otherCookie.path; >+ } >+ > String name; > String value; > String domain; >diff --git a/Source/WebCore/platform/network/cocoa/CookieCocoa.mm b/Source/WebCore/platform/network/cocoa/CookieCocoa.mm >index 307e9d49688b7871935a490a5b67ee9f7a5350b5..2217b0153789c67f2de43429f3df0c693278c18b 100644 >--- a/Source/WebCore/platform/network/cocoa/CookieCocoa.mm >+++ b/Source/WebCore/platform/network/cocoa/CookieCocoa.mm >@@ -195,7 +195,6 @@ Cookie::operator NSHTTPCookie * _Nullable () const > > bool Cookie::operator==(const Cookie& other) const > { >- ASSERT(!name.isHashTableDeletedValue()); > bool thisNull = isNull(); > bool otherNull = other.isNull(); > if (thisNull || otherNull) >diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >index 3ba29b31e0f3e89ba154587c1521a8aea7869a4f..39bb2bcfa64206b374cdf65941261025cf907273 100644 >--- a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >+++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >@@ -1941,6 +1941,13 @@ Vector<WebCore::Cookie> WebsiteDataStore::pendingCookies() const > > void WebsiteDataStore::addPendingCookie(const WebCore::Cookie& cookie) > { >+ for (auto& pendingCookie : pendingCookies()) { >+ if (pendingCookie.isKeyEqual(cookie)) { >+ m_pendingCookies.remove(pendingCookie); >+ break; >+ } >+ } >+ > m_pendingCookies.add(cookie); > } > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index e7796e197e0b351c296f4cacd9086c4310cf097a..3d41c7fc618cef06f1ead8a8b2fe8bb662393e34 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,15 @@ >+2019-06-07 Sihui Liu <sihui_liu@apple.com> >+ >+ [WKHTTPCookieStore getAllCookies:] may return duplicate cookies >+ https://bugs.webkit.org/show_bug.cgi?id=198635 >+ <rdar://problem/46010232> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm: >+ (areCookiesEqual): >+ (TEST): >+ > 2019-06-07 Wenson Hsieh <wenson_hsieh@apple.com> > > [iOS] At least 6 API tests are failing due to an exception when writing NSAttributedString to the pasteboard >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm >index 0f1e79ee16029dcb1ca8651e48efbe697b04020c..ef5cb5dc63deaccf1316ece657d0ce0ac07f405e 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm >@@ -627,3 +627,57 @@ TEST(WebKit, WKHTTPCookieStoreWithoutProcessPoolEphemeralSession) > [webView loadHTMLString:alertCookieHTML baseURL:[NSURL URLWithString:@"http://127.0.0.1"]]; > TestWebKitAPI::Util::run(&finished); > } >+ >+static bool areCookiesEqual(NSHTTPCookie *first, NSHTTPCookie *second) >+{ >+ return [first.name isEqual:second.name] && [first.domain isEqual:second.domain] && [first.path isEqual:second.path] && [first.value isEqual:second.value]; >+} >+ >+TEST(WebKit, WKHTTPCookieStoreWithoutProcessPoolDuplicates) >+{ >+ RetainPtr<WKHTTPCookieStore> httpCookieStore = [WKWebsiteDataStore defaultDataStore].httpCookieStore; >+ RetainPtr<NSHTTPCookie> sessionCookie = [NSHTTPCookie cookieWithProperties:@{ >+ NSHTTPCookiePath: @"/", >+ NSHTTPCookieName: @"SessionCookieName", >+ NSHTTPCookieValue: @"CookieValue", >+ NSHTTPCookieDomain: @"127.0.0.1", >+ }]; >+ >+ auto properties = adoptNS([sessionCookie.get().properties mutableCopy]); >+ properties.get()[NSHTTPCookieDomain] = @"localhost"; >+ RetainPtr<NSHTTPCookie> sessionCookieDifferentDomain = [NSHTTPCookie cookieWithProperties:properties.get()]; >+ properties.get()[NSHTTPCookieValue] = @"OtherCookieValue"; >+ RetainPtr<NSHTTPCookie> sessionCookieDifferentValue = [NSHTTPCookie cookieWithProperties:properties.get()]; >+ >+ [httpCookieStore.get() setCookie:sessionCookie.get() completionHandler:^{ >+ finished = true; >+ }]; >+ TestWebKitAPI::Util::run(&finished); >+ finished = false; >+ >+ [httpCookieStore.get() setCookie:sessionCookieDifferentDomain.get() completionHandler:^{ >+ finished = true; >+ }]; >+ TestWebKitAPI::Util::run(&finished); >+ finished = false; >+ >+ [httpCookieStore.get() setCookie:sessionCookieDifferentValue.get() completionHandler:^{ >+ finished = true; >+ }]; >+ TestWebKitAPI::Util::run(&finished); >+ finished = false; >+ >+ [httpCookieStore.get() getAllCookies:^(NSArray<NSHTTPCookie *> *cookies) { >+ EXPECT_EQ(2u, cookies.count); >+ bool sessionCookieExists = false, otherSessionCookieExists = false; >+ for (NSHTTPCookie* cookie in cookies) { >+ if (areCookiesEqual(cookie, sessionCookie.get())) >+ sessionCookieExists = true; >+ else if (areCookiesEqual(cookie, sessionCookieDifferentValue.get())) >+ otherSessionCookieExists = true; >+ } >+ EXPECT_TRUE(sessionCookieExists && otherSessionCookieExists); >+ finished = true; >+ }]; >+ TestWebKitAPI::Util::run(&finished); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198635
:
371543
|
371554
|
371606
|
371641
|
371643
|
371749