Skip to content

Commit

Permalink
Make host comparisons in Quirks case-sensitive
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=267687

Reviewed by Alex Christensen and Chris Dumez.

The URL parser already ensures host is canonical.

* Source/WebCore/page/Quirks.cpp:
(WebCore::isYahooMail):
(WebCore::Quirks::isTouchBarUpdateSupressedForHiddenContentEditable const):
(WebCore::Quirks::isNeverRichlyEditableForTouchBar const):
(WebCore::Quirks::shouldSuppressAutocorrectionAndAutocapitalizationInHiddenEditableAreas const):
(WebCore::Quirks::needsYouTubeMouseOutQuirk const):
(WebCore::Quirks::shouldAvoidUsingIOS13ForGmail const):
(WebCore::Quirks::shouldMakeTouchEventNonCancelableForTarget const):
(WebCore::Quirks::shouldPreventDispatchOfTouchEvent const):
(WebCore::Quirks::shouldAvoidResizingWhenInputViewBoundsChange const):
(WebCore::Quirks::needsDeferKeyDownAndKeyPressTimersUntilNextEditingCommand const):
(WebCore::Quirks::needsGMailOverflowScrollQuirk const):
(WebCore::Quirks::needsYouTubeOverflowScrollQuirk const):
(WebCore::Quirks::shouldAvoidScrollingWhenFocusedContentIsVisible const):
(WebCore::Quirks::shouldIgnoreAriaForFastPathContentObservationCheck const):
(WebCore::Quirks::shouldOpenAsAboutBlank const):
(WebCore::Quirks::shouldBypassBackForwardCache const):
(WebCore::Quirks::isMicrosoftTeamsRedirectURL):
(WebCore::Quirks::needsVP9FullRangeFlagQuirk const):
(WebCore::Quirks::shouldDisableEndFullscreenEventWhenEnteringPictureInPictureFromFullscreenQuirk const):
(WebCore::Quirks::shouldEnableFontLoadingAPIQuirk const):
(WebCore::Quirks::shouldDisablePopoverAttributeQuirk const):

Canonical link: https://commits.webkit.org/273228@main
  • Loading branch information
annevk committed Jan 19, 2024
1 parent 294802b commit a6d8d02
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions Source/WebCore/page/Quirks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static HashMap<RegistrableDomain, String>& updatableStorageAccessUserAgentString
static inline bool isYahooMail(Document& document)
{
auto host = document.topDocument().url().host();
return startsWithLettersIgnoringASCIICase(host, "mail."_s) && topPrivatelyControlledDomain(host.toString()).startsWith("yahoo."_s);
return host.startsWith("mail."_s) && topPrivatelyControlledDomain(host.toString()).startsWith("yahoo."_s);
}
#endif

Expand Down Expand Up @@ -253,8 +253,7 @@ bool Quirks::isTouchBarUpdateSupressedForHiddenContentEditable() const
if (!needsQuirks())
return false;

auto host = m_document->topDocument().url().host();
return equalLettersIgnoringASCIICase(host, "docs.google.com"_s);
return m_document->topDocument().url().host() == "docs.google.com"_s;
#else
return false;
#endif
Expand All @@ -277,13 +276,13 @@ bool Quirks::isNeverRichlyEditableForTouchBar() const
if (isDomain("twitter.com"_s))
return true;

if (equalLettersIgnoringASCIICase(host, "onedrive.live.com"_s))
if (host == "onedrive.live.com"_s)
return true;

if (isDomain("trix-editor.org"_s))
return true;

if (equalLettersIgnoringASCIICase(host, "www.icloud.com"_s)) {
if (host == "www.icloud.com"_s) {
auto path = url.path();
if (path.contains("notes"_s) || url.fragmentIdentifier().contains("notes"_s))
return true;
Expand All @@ -303,7 +302,7 @@ bool Quirks::shouldSuppressAutocorrectionAndAutocapitalizationInHiddenEditableAr
return false;

auto host = m_document->topDocument().url().host();
if (equalLettersIgnoringASCIICase(host, "docs.google.com"_s))
if (host == "docs.google.com"_s)
return true;
#endif
return false;
Expand Down Expand Up @@ -338,7 +337,7 @@ bool Quirks::needsYouTubeMouseOutQuirk() const
if (!needsQuirks())
return false;

return equalLettersIgnoringASCIICase(m_document->url().host(), "www.youtube.com"_s);
return m_document->url().host() == "www.youtube.com"_s;
#else
return false;
#endif
Expand All @@ -352,7 +351,7 @@ bool Quirks::shouldAvoidUsingIOS13ForGmail() const
return false;

auto& url = m_document->topDocument().url();
return equalLettersIgnoringASCIICase(url.host(), "mail.google.com"_s);
return url.host() == "mail.google.com"_s;
#else
return false;
#endif
Expand Down Expand Up @@ -565,7 +564,7 @@ bool Quirks::shouldMakeTouchEventNonCancelableForTarget(EventTarget* target) con

auto host = m_document->topDocument().url().host();

if (equalLettersIgnoringASCIICase(host, "www.youtube.com"_s)) {
if (host == "www.youtube.com"_s) {
if (RefPtr element = dynamicDowncast<Element>(target)) {
unsigned depth = 3;
for (; element && depth; element = element->parentElement(), --depth) {
Expand Down Expand Up @@ -593,7 +592,7 @@ bool Quirks::shouldPreventDispatchOfTouchEvent(const AtomString& touchEventType,
if (!needsQuirks())
return false;

if (RefPtr element = dynamicDowncast<Element>(target); element && touchEventType == eventNames().touchendEvent && equalLettersIgnoringASCIICase(m_document->topDocument().url().host(), "sites.google.com"_s)) {
if (RefPtr element = dynamicDowncast<Element>(target); element && touchEventType == eventNames().touchendEvent && m_document->topDocument().url().host() == "sites.google.com"_s) {
auto& classList = element->classList();
return classList.contains("DPvwYc"_s) && classList.contains("sm8sCf"_s);
}
Expand Down Expand Up @@ -637,7 +636,7 @@ bool Quirks::shouldAvoidResizingWhenInputViewBoundsChange() const
if (isDomain("google.com"_s) && url.path().startsWithIgnoringASCIICase("/maps/"_s))
return true;

if (host.endsWithIgnoringASCIICase(".sharepoint.com"_s))
if (host.endsWith(".sharepoint.com"_s))
return true;

return false;
Expand Down Expand Up @@ -667,7 +666,7 @@ bool Quirks::needsDeferKeyDownAndKeyPressTimersUntilNextEditingCommand() const
return false;

auto& url = m_document->topDocument().url();
return equalLettersIgnoringASCIICase(url.host(), "docs.google.com"_s) && startsWithLettersIgnoringASCIICase(url.path(), "/spreadsheets/"_s);
return url.host() == "docs.google.com"_s && startsWithLettersIgnoringASCIICase(url.path(), "/spreadsheets/"_s);
#else
return false;
#endif
Expand All @@ -682,7 +681,7 @@ bool Quirks::needsGMailOverflowScrollQuirk() const
return false;

if (!m_needsGMailOverflowScrollQuirk)
m_needsGMailOverflowScrollQuirk = equalLettersIgnoringASCIICase(m_document->url().host(), "mail.google.com"_s);
m_needsGMailOverflowScrollQuirk = m_document->url().host() == "mail.google.com"_s;

return *m_needsGMailOverflowScrollQuirk;
#else
Expand All @@ -699,7 +698,7 @@ bool Quirks::needsYouTubeOverflowScrollQuirk() const
return false;

if (!m_needsYouTubeOverflowScrollQuirk)
m_needsYouTubeOverflowScrollQuirk = equalLettersIgnoringASCIICase(m_document->url().host(), "www.youtube.com"_s);
m_needsYouTubeOverflowScrollQuirk = m_document->url().host() == "www.youtube.com"_s;

return *m_needsYouTubeOverflowScrollQuirk;
#else
Expand Down Expand Up @@ -823,7 +822,7 @@ bool Quirks::shouldAvoidScrollingWhenFocusedContentIsVisible() const
if (!needsQuirks())
return false;

return equalLettersIgnoringASCIICase(m_document->url().host(), "www.zillow.com"_s);
return m_document->url().host() == "www.zillow.com"_s;
}

// att.com rdar://55185021
Expand All @@ -842,8 +841,7 @@ bool Quirks::shouldIgnoreAriaForFastPathContentObservationCheck() const
if (!needsQuirks())
return false;

auto host = m_document->url().host();
return equalLettersIgnoringASCIICase(host, "www.ralphlauren.com"_s);
return m_document->url().host() == "www.ralphlauren.com"_s;
#endif
return false;
}
Expand Down Expand Up @@ -874,7 +872,7 @@ bool Quirks::shouldOpenAsAboutBlank(const String& stringToOpen) const
return false;

auto openerURL = m_document->url();
if (!equalLettersIgnoringASCIICase(openerURL.host(), "docs.google.com"_s))
if (openerURL.host() != "docs.google.com"_s)
return false;

if (!m_document->frame() || !m_document->frame()->loader().userAgent(openerURL).contains("Macintosh"_s))
Expand Down Expand Up @@ -925,7 +923,7 @@ bool Quirks::shouldBypassBackForwardCache() const
// We started caching such content in r250437 but the vimeo.com content unfortunately is not currently compatible
// because it changes the opacity of its body to 0 when navigating away and fails to restore the original opacity
// when coming back from the back/forward cache (e.g. in 'pageshow' event handler). See <rdar://problem/56996057>.
if (topURL.protocolIs("https"_s) && equalLettersIgnoringASCIICase(host, "vimeo.com"_s)) {
if (topURL.protocolIs("https"_s) && host == "vimeo.com"_s) {
if (auto* documentLoader = m_document->frame() ? m_document->frame()->loader().documentLoader() : nullptr)
return documentLoader->response().cacheControlContainsNoStore();
}
Expand Down Expand Up @@ -1111,7 +1109,7 @@ static bool isKinjaLoginAvatarElement(const Element& element)
// teams.microsoft.com https://bugs.webkit.org/show_bug.cgi?id=219505
bool Quirks::isMicrosoftTeamsRedirectURL(const URL& url)
{
return url.host() == "teams.microsoft.com"_s && url.query().toString().contains("Retried+3+times+without+success"_s);
return url.host() == "teams.microsoft.com"_s && url.query().contains("Retried+3+times+without+success"_s);
}

static bool elementHasClassInClosestAncestors(const Element& element, const AtomString& className, unsigned distance)
Expand Down Expand Up @@ -1320,7 +1318,7 @@ bool Quirks::needsVP9FullRangeFlagQuirk() const
return false;

if (!m_needsVP9FullRangeFlagQuirk)
m_needsVP9FullRangeFlagQuirk = equalLettersIgnoringASCIICase(m_document->url().host(), "www.youtube.com"_s);
m_needsVP9FullRangeFlagQuirk = m_document->url().host() == "www.youtube.com"_s;

return *m_needsVP9FullRangeFlagQuirk;
}
Expand Down Expand Up @@ -1413,7 +1411,7 @@ bool Quirks::shouldDisableEndFullscreenEventWhenEnteringPictureInPictureFromFull
auto host = m_document->topDocument().url().host();
auto domain = RegistrableDomain(m_document->topDocument().url());

m_shouldDisableEndFullscreenEventWhenEnteringPictureInPictureFromFullscreenQuirk = equalLettersIgnoringASCIICase(host, "trailers.apple.com"_s) || domain == "espn.com"_s || domain == "vimeo.com"_s;
m_shouldDisableEndFullscreenEventWhenEnteringPictureInPictureFromFullscreenQuirk = host == "trailers.apple.com"_s || domain == "espn.com"_s || domain == "vimeo.com"_s;
}

return *m_shouldDisableEndFullscreenEventWhenEnteringPictureInPictureFromFullscreenQuirk;
Expand Down Expand Up @@ -1491,7 +1489,7 @@ bool Quirks::shouldEnableFontLoadingAPIQuirk() const
return false;

if (!m_shouldEnableFontLoadingAPIQuirk)
m_shouldEnableFontLoadingAPIQuirk = equalLettersIgnoringASCIICase(m_document->url().host(), "play.hbomax.com"_s);
m_shouldEnableFontLoadingAPIQuirk = m_document->url().host() == "play.hbomax.com"_s;

return m_shouldEnableFontLoadingAPIQuirk.value();
}
Expand Down Expand Up @@ -1585,7 +1583,7 @@ bool Quirks::shouldDisablePopoverAttributeQuirk() const
return false;

auto host = m_document->topDocument().url().host();
return equalLettersIgnoringASCIICase(host, "apple-console.lrn.com"_s);
return host == "apple-console.lrn.com"_s;
}

// ungap/@custom-elements polyfill (rdar://problem/111008826).
Expand Down

0 comments on commit a6d8d02

Please sign in to comment.