Skip to content

Commit

Permalink
Remove Quirk when booking.com sends simple JPEG instead of JPEG2000 t…
Browse files Browse the repository at this point in the history
…o WebKit on iOS

https://bugs.webkit.org/show_bug.cgi?id=269876
rdar://123409087

Reviewed by Chris Dumez.

Booking.com doesn't JPEG2 anymore to Safari since March 8, 2024.
The Quirk can be removed.

* Source/WebCore/loader/FrameLoader.cpp:
(WebCore::FrameLoader::updateRequestAndAddExtraFields):
* Source/WebCore/loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::prepareFetch):
* Source/WebCore/loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::acceptHeaderValueFromType):
(WebCore::CachedResourceRequest::setAcceptHeaderIfNone):
* Source/WebCore/loader/cache/CachedResourceRequest.h:
* Source/WebCore/page/Quirks.cpp:
(WebCore::Quirks::shouldSendLongerAcceptHeaderQuirk): Deleted.
* Source/WebCore/page/Quirks.h:

Canonical link: https://commits.webkit.org/276027@main
  • Loading branch information
karlcow authored and cdumez committed Mar 13, 2024
1 parent 722de1a commit 9374282
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Source/WebCore/loader/FrameLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3241,7 +3241,7 @@ void FrameLoader::updateRequestAndAddExtraFields(ResourceRequest& request, IsMai
applyUserAgentIfNeeded(request);

if (isMainResource)
request.setHTTPHeaderField(HTTPHeaderName::Accept, CachedResourceRequest::acceptHeaderValueFromType(CachedResource::Type::MainResource, request, protectedFrame().ptr()));
request.setHTTPHeaderField(HTTPHeaderName::Accept, CachedResourceRequest::acceptHeaderValueFromType(CachedResource::Type::MainResource));

if (RefPtr document = m_frame->document(); document && frame().settings().privateTokenUsageByThirdPartyEnabled() && !frame().loader().client().isRemoteWorkerFrameLoaderClient())
request.setIsPrivateTokenUsageByThirdPartyAllowed(isFeaturePolicyAllowedByDocumentAndAllOwners(FeaturePolicy::Type::PrivateToken, *document, LogFeaturePolicyFailure::No));
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/loader/cache/CachedResourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ void CachedResourceLoader::prepareFetch(CachedResource::Type type, CachedResourc
request.setSelectedServiceWorkerRegistrationIdentifierIfNeeded(activeServiceWorker->registrationIdentifier());
}

request.setAcceptHeaderIfNone(type, protectedFrame().get());
request.setAcceptHeaderIfNone(type);

// Accept-Language value is handled in underlying port-specific code.
// FIXME: Decide whether to support client hints
Expand Down
10 changes: 3 additions & 7 deletions Source/WebCore/loader/cache/CachedResourceRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,10 @@ static String acceptHeaderValueForImageResource()
return builder.toString();
}

String CachedResourceRequest::acceptHeaderValueFromType(CachedResource::Type type, ResourceRequest& request, LocalFrame* frame)
String CachedResourceRequest::acceptHeaderValueFromType(CachedResource::Type type)
{
auto url = request.url();

switch (type) {
case CachedResource::Type::MainResource:
if (Quirks::shouldSendLongerAcceptHeaderQuirk(url, frame))
return "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"_s;
return "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"_s;
case CachedResource::Type::ImageResource:
return acceptHeaderValueForImageResource();
Expand All @@ -192,10 +188,10 @@ String CachedResourceRequest::acceptHeaderValueFromType(CachedResource::Type typ
}
}

void CachedResourceRequest::setAcceptHeaderIfNone(CachedResource::Type type, LocalFrame* frame)
void CachedResourceRequest::setAcceptHeaderIfNone(CachedResource::Type type)
{
if (!m_resourceRequest.hasHTTPHeader(HTTPHeaderName::Accept))
m_resourceRequest.setHTTPHeaderField(HTTPHeaderName::Accept, acceptHeaderValueFromType(type, m_resourceRequest, frame));
m_resourceRequest.setHTTPHeaderField(HTTPHeaderName::Accept, acceptHeaderValueFromType(type));
}

void CachedResourceRequest::disableCachingIfNeeded()
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/loader/cache/CachedResourceRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class CachedResourceRequest {
void updateReferrerAndOriginHeaders(FrameLoader&);
void updateUserAgentHeader(FrameLoader&);
void upgradeInsecureRequestIfNeeded(Document&, ContentSecurityPolicy::AlwaysUpgradeRequest = ContentSecurityPolicy::AlwaysUpgradeRequest::No);
void setAcceptHeaderIfNone(CachedResource::Type, LocalFrame*);
void setAcceptHeaderIfNone(CachedResource::Type);
void updateAccordingCacheMode();
void updateAcceptEncodingHeader();
void updateCacheModeIfNeeded(CachePolicy);
Expand All @@ -113,7 +113,7 @@ class CachedResourceRequest {
void clearFragmentIdentifier() { m_fragmentIdentifier = { }; }

static String splitFragmentIdentifierFromRequestURL(ResourceRequest&);
static String acceptHeaderValueFromType(CachedResource::Type, ResourceRequest&, LocalFrame*);
static String acceptHeaderValueFromType(CachedResource::Type);

void setClientIdentifierIfNeeded(ScriptExecutionContextIdentifier);
void setSelectedServiceWorkerRegistrationIdentifierIfNeeded(ServiceWorkerRegistrationIdentifier);
Expand Down
14 changes: 0 additions & 14 deletions Source/WebCore/page/Quirks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1722,20 +1722,6 @@ bool Quirks::shouldDisableNavigatorStandaloneQuirk() const
return false;
}

// booking.com https://webkit.org/b/269875
// FIXME: booking.com https://webkit.org/b/269876 when outreach has been successful.
bool Quirks::shouldSendLongerAcceptHeaderQuirk(const URL& url, LocalFrame* frame)
{
if (frame && !frame->settings().needsSiteSpecificQuirks())
return false;

auto host = url.host();
if (host == "booking.com"_s || host.endsWith(".booking.com"_s))
return true;

return false;
}

// This section is dedicated to UA override for iPad. iPads (but iPad Mini) are sending a desktop user agent
// to websites. In some cases, the website breaks in some ways, not expecting a touch interface for the website.
// Controls not active or too small, form factor, etc. In this case it is better to send the iPad Mini UA.
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/page/Quirks.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class Quirks {
bool shouldExposeShowModalDialog() const;
bool shouldNavigatorPluginsBeEmpty() const;
bool shouldDisableNavigatorStandaloneQuirk() const;
static bool shouldSendLongerAcceptHeaderQuirk(const URL&, LocalFrame*);

WEBCORE_EXPORT bool shouldDispatchSyntheticMouseEventsWhenModifyingSelection() const;
WEBCORE_EXPORT bool shouldSuppressAutocorrectionAndAutocapitalizationInHiddenEditableAreas() const;
Expand Down

0 comments on commit 9374282

Please sign in to comment.