Make both filterForRegistrableDomains() in WebKit::NetworkProcess use WebCore::Regist...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 May 2019 20:55:44 +0000 (20:55 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 May 2019 20:55:44 +0000 (20:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197521
<rdar://problem/49651503>

Patch by John Wilander <wilander@apple.com> on 2019-05-02
Reviewed by Brent Fulgham.

Source/WebKit:

* NetworkProcess/NetworkProcess.cpp:
(WebKit::filterForRegistrableDomains):

Tools:

* TestWebKitAPI/Tests/WebCore/RegistrableDomain.cpp:
(TestWebKitAPI::TEST):
   Added a test for host strings with leading dots since they are
   often used for the domain attribute in cookies.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244884 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebCore/RegistrableDomain.cpp

index e9df2bd..a0c7d1f 100644 (file)
@@ -1,3 +1,14 @@
+2019-05-02  John Wilander  <wilander@apple.com>
+
+        Make both filterForRegistrableDomains() in WebKit::NetworkProcess use WebCore::RegistrableDomain::uncheckedCreateFromHost()
+        https://bugs.webkit.org/show_bug.cgi?id=197521
+        <rdar://problem/49651503>
+
+        Reviewed by Brent Fulgham.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::filterForRegistrableDomains):
+
 2019-05-02  Per Arne Vollan  <pvollan@apple.com>
 
         -[WKWebsiteDataStore removeDataOfTypes:forDataRecords:completionHandler:] doesn't delete _WKWebsiteDataTypeCredentials
index a9086d9..4987420 100644 (file)
@@ -1522,9 +1522,9 @@ void NetworkProcess::clearStorageQuota(PAL::SessionID sessionID)
 static Vector<String> filterForRegistrableDomains(const Vector<RegistrableDomain>& registrableDomains, const HashSet<String>& foundValues)
 {
     Vector<String> result;
-    for (const auto& domain : registrableDomains) {
-        if (foundValues.contains(domain.string()))
-            result.append(domain.string());
+    for (const auto& value : foundValues) {
+        if (registrableDomains.contains(RegistrableDomain::uncheckedCreateFromHost(value)))
+            result.append(value);
     }
     
     return result;
index 296c057..479ac50 100644 (file)
@@ -1,3 +1,16 @@
+2019-05-02  John Wilander  <wilander@apple.com>
+
+        Make both filterForRegistrableDomains() in WebKit::NetworkProcess use WebCore::RegistrableDomain::uncheckedCreateFromHost()
+        https://bugs.webkit.org/show_bug.cgi?id=197521
+        <rdar://problem/49651503>
+
+        Reviewed by Brent Fulgham.
+
+        * TestWebKitAPI/Tests/WebCore/RegistrableDomain.cpp:
+        (TestWebKitAPI::TEST):
+           Added a test for host strings with leading dots since they are
+           often used for the domain attribute in cookies.
+
 2019-05-02  Per Arne Vollan  <pvollan@apple.com>
 
         -[WKWebsiteDataStore removeDataOfTypes:forDataRecords:completionHandler:] doesn't delete _WKWebsiteDataTypeCredentials
index 7006308..6c8a511 100644 (file)
@@ -82,4 +82,15 @@ TEST(RegistrableDomain, MatchesURLs)
     ASSERT_FALSE(webkitDomain.matches(ebkitURL));
 }
 
+TEST(RegistrableDomain, UncheckedCreateFromHost)
+{
+    auto webkitDomainFromString = RegistrableDomain::uncheckedCreateFromRegistrableDomainString("webkit.org");
+
+    auto webkitDomainFromHost = RegistrableDomain::uncheckedCreateFromHost("webkit.org");
+    ASSERT_EQ(webkitDomainFromHost, webkitDomainFromString);
+    // This test is important for matching cookies' domain attributes which often have a leading dot.
+    auto dotWebkitDomainFromHost = RegistrableDomain::uncheckedCreateFromHost(".webkit.org");
+    ASSERT_EQ(dotWebkitDomainFromHost, webkitDomainFromString);
+}
+
 } // namespace TestWebKitAPI