Title: [257139] trunk
Revision
257139
Author
[email protected]
Date
2020-02-21 09:22:38 -0800 (Fri, 21 Feb 2020)

Log Message

[WPE][GTK] googleapis.com is a public suffix, defeating isGoogle() check in UserAgentQuirks.cpp
https://bugs.webkit.org/show_bug.cgi?id=207984

Patch by Michael Catanzaro <[email protected]> on 2020-02-21
Reviewed by Daniel Bates.

Source/WebCore:

Fix the check for googleapis.com. Since it's now a public suffix, we can no longer check the
URL's base domain here. Instead, we can check endsWith().

I considered switching to endsWith() for all the checks in this file, to make our user agent
quirks robust to future changes in the public suffix list, but checking the base domain is
nicer and it seems unnecessary. We can continue to adjust our quirks in the future as
necessary.

The public suffix list:
https://github.com/publicsuffix/list/blob/7922d7c20e246552be418e8f72e577899fd30d99/public_suffix_list.dat#L11922

* platform/UserAgentQuirks.cpp:
(WebCore::isGoogle):

Tools:

* TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (257138 => 257139)


--- trunk/Source/WebCore/ChangeLog	2020-02-21 17:21:45 UTC (rev 257138)
+++ trunk/Source/WebCore/ChangeLog	2020-02-21 17:22:38 UTC (rev 257139)
@@ -1,3 +1,24 @@
+2020-02-21  Michael Catanzaro  <[email protected]>
+
+        [WPE][GTK] googleapis.com is a public suffix, defeating isGoogle() check in UserAgentQuirks.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=207984
+
+        Reviewed by Daniel Bates.
+
+        Fix the check for googleapis.com. Since it's now a public suffix, we can no longer check the
+        URL's base domain here. Instead, we can check endsWith().
+
+        I considered switching to endsWith() for all the checks in this file, to make our user agent
+        quirks robust to future changes in the public suffix list, but checking the base domain is
+        nicer and it seems unnecessary. We can continue to adjust our quirks in the future as
+        necessary.
+
+        The public suffix list:
+        https://github.com/publicsuffix/list/blob/7922d7c20e246552be418e8f72e577899fd30d99/public_suffix_list.dat#L11922
+
+        * platform/UserAgentQuirks.cpp:
+        (WebCore::isGoogle):
+
 2020-02-21  Simon Fraser  <[email protected]>
 
         [Web Animations] Repeated animations on pseudo elements will fail to run after a while

Modified: trunk/Source/WebCore/platform/UserAgentQuirks.cpp (257138 => 257139)


--- trunk/Source/WebCore/platform/UserAgentQuirks.cpp	2020-02-21 17:21:45 UTC (rev 257138)
+++ trunk/Source/WebCore/platform/UserAgentQuirks.cpp	2020-02-21 17:22:38 UTC (rev 257139)
@@ -36,7 +36,8 @@
 
 static bool isGoogle(const URL& url)
 {
-    String baseDomain = topPrivatelyControlledDomain(url.host().toString());
+    String domain = url.host().toString();
+    String baseDomain = topPrivatelyControlledDomain(domain);
 
     // Our Google UA is *very* complicated to get right. Read
     // https://webkit.org/b/142074 carefully before changing. Test that 3D
@@ -47,10 +48,12 @@
         return true;
     if (baseDomain == "gstatic.com")
         return true;
-    if (baseDomain == "googleapis.com")
-        return true;
     if (baseDomain == "googleusercontent.com")
         return true;
+    // googleapis.com is in the public suffix list, which is confusing. E.g.
+    // fonts.googleapis.com is actually a base domain.
+    if (domain.endsWith(".googleapis.com"))
+        return true;
 
     return false;
 }

Modified: trunk/Tools/ChangeLog (257138 => 257139)


--- trunk/Tools/ChangeLog	2020-02-21 17:21:45 UTC (rev 257138)
+++ trunk/Tools/ChangeLog	2020-02-21 17:22:38 UTC (rev 257139)
@@ -1,3 +1,13 @@
+2020-02-21  Michael Catanzaro  <[email protected]>
+
+        [WPE][GTK] googleapis.com is a public suffix, defeating isGoogle() check in UserAgentQuirks.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=207984
+
+        Reviewed by Daniel Bates.
+
+        * TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp:
+        (TestWebKitAPI::TEST):
+
 2020-02-20  Michael Catanzaro  <[email protected]>
 
         [GTK] Improve user agent quirk for Google Docs and Google Drive

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp (257138 => 257139)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp	2020-02-21 17:21:45 UTC (rev 257138)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp	2020-02-21 17:22:38 UTC (rev 257139)
@@ -99,6 +99,7 @@
     assertUserAgentForURLHasLinuxPlatformQuirk("http://calendar.google.com/");
     assertUserAgentForURLHasLinuxPlatformQuirk("http://plus.google.com/");
     assertUserAgentForURLHasLinuxPlatformQuirk("http://drive.google.com/");
+    assertUserAgentForURLHasLinuxPlatformQuirk("http://fonts.googleapis.com/");
 
     assertUserAgentForURLHasMacPlatformQuirk("http://www.yahoo.com/");
     assertUserAgentForURLHasMacPlatformQuirk("http://finance.yahoo.com/");
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to