Skip to content

Commit

Permalink
Remove ENABLE_PUBLIC_SUFFIX_LIST directive
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=271157

Reviewed by Sihui Liu.

It's enabled on all ports.

* Source/WTF/wtf/PlatformEnableCocoa.h:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::urlForBindings const):
* Source/WebCore/loader/CrossOriginAccessControl.cpp:
(WebCore::shouldCrossOriginResourcePolicyCancelLoad):
* Source/WebCore/loader/cache/CachedResourceLoader.cpp:
(WebCore::updateRequestFetchMetadataHeaders):
(WebCore::CachedResourceLoader::updateRequestAfterRedirection):
(WebCore::CachedResourceLoader::updateHTTPRequestHeaders):
* Source/WebCore/page/PerformanceMonitor.cpp:
(WebCore::reportPageOverPostLoadResourceThreshold):
* Source/WebCore/page/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::isSameSiteAs const):
(WebCore::SecurityOrigin::isMatchingRegistrableDomainSuffix const):
* Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp:
(WebCore::ContentSecurityPolicySourceList::isValidSourceForExtensionMode):
* Source/WebCore/platform/PublicSuffix.h:
* Source/WebCore/platform/RegistrableDomain.h:
(WebCore::RegistrableDomain::uncheckedCreateFromHost):
(WebCore::RegistrableDomain::registrableDomainFromHost):
* Source/WebCore/platform/cocoa/PublicSuffixCocoa.mm:
* Source/WebCore/platform/glib/UserAgentQuirks.cpp:
(WebCore::urlRequiresChromeBrowser):
(WebCore::urlRequiresMacintoshPlatform):
(WebCore::UserAgentQuirks::quirksForURL):
* Source/WebCore/platform/network/NetworkStorageSession.cpp:
* Source/WebCore/platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::partitionName):
* Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp:
* Source/WebCore/platform/network/curl/CookieJarDB.cpp:
(WebCore::CookieJarDB::hasCookies):
(WebCore::CookieJarDB::canAcceptCookie):
* Source/WebCore/platform/network/curl/PublicSuffixCurl.cpp:
* Source/WebCore/platform/soup/PublicSuffixSoup.cpp:
* Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp:
(WebKit::NetworkDataTaskSoup::shouldAllowHSTSPolicySetting const):
* Source/WebKit/Shared/LoadParameters.h:
* Source/WebKit/Shared/LoadParameters.serialization.in:
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::goToBackForwardItem):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::launchProcessForReload):
(WebKit::WebPageProxy::loadRequestWithNavigationShared):
(WebKit::WebPageProxy::loadFile):
(WebKit::WebPageProxy::goToBackForwardItem):
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch):
(WebKit::WebProcessProxy::didExceedMemoryFootprintThreshold):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataRecord.cpp:
(WebKit::WebsiteDataRecord::displayNameForHostName):
(WebKit::WebsiteDataRecord::displayNameForOrigin):
(WebKit::WebsiteDataRecord::topPrivatelyControlledDomain):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::goToBackForwardItem):
* Source/cmake/OptionsWin.cmake:
* Source/cmake/WebKitFeatures.cmake:
* Tools/Scripts/webkitperl/FeatureList.pm:
* Tools/TestWebKitAPI/Tests/WebCore/PublicSuffix.cpp:
* Tools/TestWebKitAPI/Tests/WebCore/SecurityOrigin.cpp:
(TestWebKitAPI::TEST_F):

Canonical link: https://commits.webkit.org/276305@main
  • Loading branch information
annevk committed Mar 18, 2024
1 parent f342b3f commit 2a6c7d3
Show file tree
Hide file tree
Showing 30 changed files with 7 additions and 150 deletions.
4 changes: 0 additions & 4 deletions Source/WTF/wtf/PlatformEnableCocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,6 @@
#define ENABLE_PREWARM_WEBPROCESS_ON_PROVISIONAL_LOAD 1
#endif

#if !defined(ENABLE_PUBLIC_SUFFIX_LIST)
#define ENABLE_PUBLIC_SUFFIX_LIST 1
#endif

#if !defined(ENABLE_REMOTE_INSPECTOR)
#define ENABLE_REMOTE_INSPECTOR 1
#endif
Expand Down
4 changes: 0 additions & 4 deletions Source/WebCore/dom/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4064,7 +4064,6 @@ const URL& Document::urlForBindings() const
if (preNavigationURL.isEmpty() || RegistrableDomain { preNavigationURL }.matches(securityOrigin().data()))
return false;

#if ENABLE(PUBLIC_SUFFIX_LIST)
auto areSameSiteIgnoringPublicSuffix = [](StringView domain, StringView otherDomain) {
auto domainString = topPrivatelyControlledDomain(domain.toStringWithoutCopying());
auto otherDomainString = topPrivatelyControlledDomain(otherDomain.toStringWithoutCopying());
Expand All @@ -4081,7 +4080,6 @@ const URL& Document::urlForBindings() const
auto currentHost = securityOrigin().data().host();
if (areSameSiteIgnoringPublicSuffix(preNavigationURL.host(), currentHost))
return false;
#endif // ENABLE(PUBLIC_SUFFIX_LIST)

if (!m_hasLoadedThirdPartyScript)
return false;
Expand All @@ -4090,10 +4088,8 @@ const URL& Document::urlForBindings() const
if (RegistrableDomain { sourceURL }.matches(securityOrigin().data()))
return false;

#if ENABLE(PUBLIC_SUFFIX_LIST)
if (areSameSiteIgnoringPublicSuffix(sourceURL.host(), currentHost))
return false;
#endif // ENABLE(PUBLIC_SUFFIX_LIST)
}

return true;
Expand Down
2 changes: 0 additions & 2 deletions Source/WebCore/loader/CrossOriginAccessControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,8 @@ static inline bool shouldCrossOriginResourcePolicyCancelLoad(CrossOriginEmbedder
if (policy == CrossOriginResourcePolicy::SameSite) {
if (origin.isOpaque())
return true;
#if ENABLE(PUBLIC_SUFFIX_LIST)
if (!RegistrableDomain::uncheckedCreateFromHost(origin.host()).matches(responseURL))
return true;
#endif
if (origin.protocol() == "http"_s && responseURL.protocol() == "https"_s)
return true;
}
Expand Down
8 changes: 0 additions & 8 deletions Source/WebCore/loader/cache/CachedResourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ bool CachedResourceLoader::canRequestAfterRedirection(CachedResource::Type type,
String convertEnumerationToString(FetchOptions::Destination);
String convertEnumerationToString(FetchOptions::Mode);

#if ENABLE(PUBLIC_SUFFIX_LIST)
static const String& convertEnumerationToString(FetchMetadataSite enumerationValue)
{
static NeverDestroyed<const String> none(MAKE_STATIC_STRING_IMPL("none"));
Expand Down Expand Up @@ -721,7 +720,6 @@ static void updateRequestFetchMetadataHeaders(ResourceRequest& request, const Re
request.setHTTPHeaderField(HTTPHeaderName::SecFetchMode, convertEnumerationToString(options.mode));
request.setHTTPHeaderField(HTTPHeaderName::SecFetchSite, convertEnumerationToString(site));
}
#endif // ENABLE(PUBLIC_SUFFIX_LIST)

FetchMetadataSite CachedResourceLoader::computeFetchMetadataSite(const ResourceRequest& request, CachedResource::Type type, FetchOptions::Mode mode, const SecurityOrigin& originalOrigin, FetchMetadataSite originalSite)
{
Expand Down Expand Up @@ -753,7 +751,6 @@ bool CachedResourceLoader::updateRequestAfterRedirection(CachedResource::Type ty

// FIXME: We might want to align the checks done here with the ones done in CachedResourceLoader::requestResource, content extensions blocking in particular.

#if ENABLE(PUBLIC_SUFFIX_LIST)
RefPtr frame = m_documentLoader->frame();
if (frame && (!frame->document() || !frame->document()->quirks().shouldDisableFetchMetadata())) {
Ref requestOrigin = SecurityOrigin::create(request.url());
Expand All @@ -767,9 +764,6 @@ bool CachedResourceLoader::updateRequestAfterRedirection(CachedResource::Type ty
} else
updateRequestFetchMetadataHeaders(request, options, site);
}
#else
UNUSED_PARAM(site);
#endif // ENABLE(PUBLIC_SUFFIX_LIST)

return canRequestAfterRedirection(type, request.url(), options, preRedirectURL);
}
Expand Down Expand Up @@ -923,15 +917,13 @@ void CachedResourceLoader::updateHTTPRequestHeaders(FrameLoader& frameLoader, Ca
// FIXME: We should reconcile handling of MainResource with other resources.
if (type != CachedResource::Type::MainResource)
request.updateReferrerAndOriginHeaders(frameLoader);
#if ENABLE(PUBLIC_SUFFIX_LIST)
// FetchMetadata depends on PSL to determine same-site relationships and without this
// ability it is best to not set any FetchMetadata headers as sites generally expect
// all of them or none.
if (!frameLoader.frame().document() || !frameLoader.frame().document()->quirks().shouldDisableFetchMetadata()) {
auto site = computeFetchMetadataSite(request.resourceRequest(), type, request.options().mode, frameLoader.frame().document()->protectedSecurityOrigin());
updateRequestFetchMetadataHeaders(request.resourceRequest(), request.options(), site);
}
#endif // ENABLE(PUBLIC_SUFFIX_LIST)
request.updateUserAgentHeader(frameLoader);

if (frameLoader.frame().loader().loadType() == FrameLoadType::ReloadFromOrigin)
Expand Down
5 changes: 0 additions & 5 deletions Source/WebCore/page/PerformanceMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ void PerformanceMonitor::activityStateChanged(OptionSet<ActivityState> oldState,
enum class ReportingReason { HighCPUUsage, HighMemoryUsage };
static void reportPageOverPostLoadResourceThreshold(Page& page, ReportingReason reason)
{
#if ENABLE(PUBLIC_SUFFIX_LIST)
auto* localMainFrame = dynamicDowncast<LocalFrame>(page.mainFrame());
if (!localMainFrame)
return;
Expand All @@ -164,10 +163,6 @@ static void reportPageOverPostLoadResourceThreshold(Page& page, ReportingReason
page.diagnosticLoggingClient().logDiagnosticMessageWithEnhancedPrivacy(DiagnosticLoggingKeys::domainCausingJetsamKey(), registrableDomain.string(), ShouldSample::No);
break;
}
#else
UNUSED_PARAM(page);
UNUSED_PARAM(reason);
#endif
}

void PerformanceMonitor::measurePostLoadCPUUsage()
Expand Down
8 changes: 0 additions & 8 deletions Source/WebCore/page/SecurityOrigin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ bool SecurityOrigin::isSameOriginAs(const SecurityOrigin& other) const

bool SecurityOrigin::isSameSiteAs(const SecurityOrigin& other) const
{
#if ENABLE(PUBLIC_SUFFIX_LIST)
// https://html.spec.whatwg.org/#same-site
if (isOpaque() != other.isOpaque())
return false;
Expand All @@ -429,9 +428,6 @@ bool SecurityOrigin::isSameSiteAs(const SecurityOrigin& other) const
return host() == other.host();

return topDomain == topPrivatelyControlledDomain(other.domain());
#else
return isSameOriginAs(other);
#endif // ENABLE(PUBLIC_SUFFIX_LIST)
}

bool SecurityOrigin::isMatchingRegistrableDomainSuffix(const String& domainSuffix, bool treatIPAddressAsDomain) const
Expand All @@ -448,11 +444,7 @@ bool SecurityOrigin::isMatchingRegistrableDomainSuffix(const String& domainSuffi
if (domainSuffix.length() == host().length())
return true;

#if ENABLE(PUBLIC_SUFFIX_LIST)
return !isPublicSuffix(domainSuffix);
#else
return true;
#endif
}

bool SecurityOrigin::isPotentiallyTrustworthy() const
Expand Down
7 changes: 1 addition & 6 deletions Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,14 @@ static bool isRestrictedDirectiveForMode(const String& directive, ContentSecurit

bool ContentSecurityPolicySourceList::isValidSourceForExtensionMode(const ContentSecurityPolicySourceList::Source& parsedSource)
{
bool hostIsPublicSuffix = false;
#if ENABLE(PUBLIC_SUFFIX_LIST)
hostIsPublicSuffix = isPublicSuffix(parsedSource.host.value);
#endif

switch (m_contentSecurityPolicyModeForExtension) {
case ContentSecurityPolicyModeForExtension::None:
return true;
case ContentSecurityPolicyModeForExtension::ManifestV2:
if (!isRestrictedDirectiveForMode(m_directiveName, ContentSecurityPolicyModeForExtension::ManifestV2))
return true;

if (parsedSource.host.hasWildcard && hostIsPublicSuffix)
if (parsedSource.host.hasWildcard && isPublicSuffix(parsedSource.host.value))
return false;

if (equalLettersIgnoringASCIICase(parsedSource.scheme, "blob"_s))
Expand Down
4 changes: 0 additions & 4 deletions Source/WebCore/platform/PublicSuffix.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

#include <wtf/text/WTFString.h>

#if ENABLE(PUBLIC_SUFFIX_LIST)

namespace WebCore {

WEBCORE_EXPORT bool isPublicSuffix(StringView domain);
Expand All @@ -37,5 +35,3 @@ WEBCORE_EXPORT void setTopPrivatelyControlledDomain(const String& domain, const
String decodeHostName(const String& domain);

} // namespace WebCore

#endif // ENABLE(PUBLIC_SUFFIX_LIST)
8 changes: 0 additions & 8 deletions Source/WebCore/platform/RegistrableDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,10 @@ class RegistrableDomain {

static RegistrableDomain uncheckedCreateFromHost(const String& host)
{
#if ENABLE(PUBLIC_SUFFIX_LIST)
auto registrableDomain = topPrivatelyControlledDomain(host);
if (registrableDomain.isEmpty())
return uncheckedCreateFromRegistrableDomainString(host);
return RegistrableDomain { WTFMove(registrableDomain) };
#else
return uncheckedCreateFromRegistrableDomainString(host);
#endif
}

private:
Expand All @@ -120,11 +116,7 @@ class RegistrableDomain {

static inline String registrableDomainFromHost(const String& host)
{
#if ENABLE(PUBLIC_SUFFIX_LIST)
auto domain = topPrivatelyControlledDomain(host);
#else
auto domain = host;
#endif
if (host.isEmpty())
domain = "nullOrigin"_s;
else if (domain.isEmpty())
Expand Down
4 changes: 0 additions & 4 deletions Source/WebCore/platform/cocoa/PublicSuffixCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#import "config.h"
#import "PublicSuffix.h"

#if ENABLE(PUBLIC_SUFFIX_LIST)

#import <pal/spi/cf/CFNetworkSPI.h>
#import <wtf/HashMap.h>
#import <wtf/text/StringHash.h>
Expand Down Expand Up @@ -94,5 +92,3 @@ String decodeHostName(const String& domain)
}

}

#endif
9 changes: 0 additions & 9 deletions Source/WebCore/platform/glib/UserAgentQuirks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ namespace WebCore {
// When testing changes, be sure to test with application branding enabled.
// Otherwise, we will not notice when urlRequiresUnbrandedUserAgent is needed.

#if ENABLE(PUBLIC_SUFFIX_LIST)
// Be careful with this quirk: it's an invitation for sites to use JavaScript
// that works in Chrome that WebKit cannot handle. Prefer other quirks instead.
static bool urlRequiresChromeBrowser(const String& domain, const String& baseDomain)
Expand Down Expand Up @@ -77,7 +76,6 @@ static bool urlRequiresChromeBrowser(const String& domain, const String& baseDom

return false;
}
#endif // ENABLE(PUBLIC_SUFFIX_LIST)

// Prefer using the macOS platform quirk rather than the Firefox quirk. This
// quirk is good for websites that do macOS-specific things we don't want on
Expand All @@ -98,7 +96,6 @@ static bool urlRequiresFirefoxBrowser(const String& domain)
return false;
}

#if ENABLE(PUBLIC_SUFFIX_LIST)
static bool urlRequiresMacintoshPlatform(const String& domain, const String& baseDomain)
{
// At least finance.yahoo.com displays a mobile version with WebKitGTK's standard user agent.
Expand Down Expand Up @@ -144,7 +141,6 @@ static bool urlRequiresMacintoshPlatform(const String& domain, const String& bas

return false;
}
#endif // ENABLE(PUBLIC_SUFFIX_LIST)

static bool urlRequiresUnbrandedUserAgent(const String& domain)
{
Expand Down Expand Up @@ -172,7 +168,6 @@ UserAgentQuirks UserAgentQuirks::quirksForURL(const URL& url)

String domain = url.host().toString();
UserAgentQuirks quirks;
#if ENABLE(PUBLIC_SUFFIX_LIST)
String baseDomain = topPrivatelyControlledDomain(domain);

if (urlRequiresChromeBrowser(domain, baseDomain))
Expand All @@ -182,10 +177,6 @@ UserAgentQuirks UserAgentQuirks::quirksForURL(const URL& url)

if (urlRequiresMacintoshPlatform(domain, baseDomain))
quirks.add(UserAgentQuirks::NeedsMacintoshPlatform);
#else
if (urlRequiresFirefoxBrowser(domain))
quirks.add(UserAgentQuirks::NeedsFirefoxBrowser);
#endif

if (urlRequiresUnbrandedUserAgent(domain))
quirks.add(UserAgentQuirks::NeedsUnbrandedUserAgent);
Expand Down
5 changes: 1 addition & 4 deletions Source/WebCore/platform/network/NetworkStorageSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@
#include "CookieJar.h"
#include "HTTPCookieAcceptPolicy.h"
#include "NotImplemented.h"
#include "PublicSuffix.h"
#include "ResourceRequest.h"
#include "RuntimeApplicationChecks.h"
#include <wtf/NeverDestroyed.h>
#include <wtf/ProcessPrivilege.h>
#include <wtf/RunLoop.h>

#if ENABLE(PUBLIC_SUFFIX_LIST)
#include "PublicSuffix.h"
#endif

namespace WebCore {

static HashSet<OrganizationStorageAccessPromptQuirk>& updatableStorageAccessPromptQuirks()
Expand Down
8 changes: 0 additions & 8 deletions Source/WebCore/platform/network/ResourceRequestBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,20 +827,12 @@ void ResourceRequestBase::setCachePartition(const String& cachePartition)

String ResourceRequestBase::partitionName(const String& domain)
{
#if ENABLE(PUBLIC_SUFFIX_LIST)
if (domain.isNull())
return emptyString();
String highLevel = topPrivatelyControlledDomain(domain);
if (highLevel.isNull())
return emptyString();
return highLevel;
#else
UNUSED_PARAM(domain);
#if ENABLE(CACHE_PARTITIONING)
#error Cache partitioning requires PUBLIC_SUFFIX_LIST
#endif
return emptyString();
#endif
}

bool ResourceRequestBase::isThirdParty() const
Expand Down
5 changes: 1 addition & 4 deletions Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@
#include "ResourceRequestCFNet.h"

#include "HTTPHeaderNames.h"
#include "PublicSuffix.h"
#include "RegistrableDomain.h"
#include "ResourceLoadPriority.h"
#include "ResourceRequest.h"
#include <dlfcn.h>
#include <pal/spi/cf/CFNetworkSPI.h>
#include <wtf/cf/TypeCastsCF.h>

#if ENABLE(PUBLIC_SUFFIX_LIST)
#include "PublicSuffix.h"
#endif

namespace WebCore {

// FIXME: Make this a NetworkingContext property.
Expand Down
4 changes: 0 additions & 4 deletions Source/WebCore/platform/network/curl/CookieJarDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,8 @@ bool CookieJarDB::hasCookies(const URL& url)
if (host.isEmpty())
return false;

#if ENABLE(PUBLIC_SUFFIX_LIST)
if (isPublicSuffix(host))
return false;
#endif

RegistrableDomain registrableDomain { url };
auto& statement = preparedStatement(CHECK_EXISTS_COOKIE_SQL);
Expand Down Expand Up @@ -502,10 +500,8 @@ static bool checkSecureCookie(const Cookie& cookie)

bool CookieJarDB::canAcceptCookie(const Cookie& cookie, const URL& firstParty, const URL& url, CookieJarDB::Source source)
{
#if ENABLE(PUBLIC_SUFFIX_LIST)
if (isPublicSuffix(cookie.domain))
return false;
#endif

bool fromJavaScript = source == CookieJarDB::Source::Script;
if (fromJavaScript && (cookie.httpOnly || hasHttpOnlyCookie(cookie.name, cookie.domain, cookie.path)))
Expand Down
4 changes: 0 additions & 4 deletions Source/WebCore/platform/network/curl/PublicSuffixCurl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include "config.h"
#include "PublicSuffix.h"

#if ENABLE(PUBLIC_SUFFIX_LIST)

#include <libpsl.h>
#include <wtf/URL.h>

Expand Down Expand Up @@ -86,5 +84,3 @@ void setTopPrivatelyControlledDomain(const String&, const String&)
}

} // namespace WebCore

#endif // ENABLE(PUBLIC_SUFFIX_LIST)
4 changes: 0 additions & 4 deletions Source/WebCore/platform/soup/PublicSuffixSoup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include "config.h"
#include "PublicSuffix.h"

#if ENABLE(PUBLIC_SUFFIX_LIST)

#include <libsoup/soup.h>
#include <wtf/glib/GUniquePtr.h>

Expand Down Expand Up @@ -107,5 +105,3 @@ void setTopPrivatelyControlledDomain(const String&, const String&)
}

} // namespace WebCore

#endif // ENABLE(PUBLIC_SUFFIX_LIST)
Loading

0 comments on commit 2a6c7d3

Please sign in to comment.