Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Source/WebCore/platform/MIMETypeRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,12 @@ bool MIMETypeRegistry::isPDFMIMEType(const String& mimeType)

bool MIMETypeRegistry::canShowMIMEType(const String& mimeType)
{
if (isSupportedImageMIMEType(mimeType) || isSupportedNonImageMIMEType(mimeType) || isSupportedMediaMIMEType(mimeType))
return canShowNonMediaMIMEType(mimeType) || isSupportedMediaMIMEType(mimeType);
}

bool MIMETypeRegistry::canShowNonMediaMIMEType(const String& mimeType)
{
if (isSupportedImageMIMEType(mimeType) || isSupportedNonImageMIMEType(mimeType))
return true;

if (isSupportedJavaScriptMIMEType(mimeType) || isSupportedJSONMIMEType(mimeType))
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/platform/MIMETypeRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class MIMETypeRegistry {
// isUnsupportedTextMIMEType() returns false.
WEBCORE_EXPORT static bool canShowMIMEType(const String& mimeType);

// Like canShowMIMEType(), without isSupportedMediaMIMEType(), which asks the media engines.
WEBCORE_EXPORT static bool canShowNonMediaMIMEType(const String& mimeType);

// Check to see if a MIME type is one where an XML document should be created
// rather than an HTML document.
WEBCORE_EXPORT static bool isXMLMIMEType(const String& mimeType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ Vector<String> extractGStreamerOptionsFromCommandLine()
bool ensureGStreamerInitializedNonWebProcess()
{
RELEASE_ASSERT(!isInWebProcess());
RELEASE_ASSERT(!isInNetworkProcess());

static std::once_flag onceFlag;
static bool isGStreamerInitialized;
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,8 @@ void NetworkDataTaskSoup::didGetFileInfo(GFileInfo* info)
auto mimeTypeFromContent = extractMIMETypeFromMediaType(contentType);
// If an application calls g_app_info_get_default_for_type($ext) then Glib will return "application/x-extension-$ext" in mimeTypeFromExtension which WebKit doesn't know how to handle.
// So, only prefer mimeTypeFromExtension if that is a mimeType that WebKit recognizes internally. See: https://gitlab.gnome.org/GNOME/glib/-/issues/2511
if (MIMETypeRegistry::canShowMIMEType(mimeTypeFromExtension) || mimeTypeFromContent.isEmpty())
bool isMediaType = startsWithLettersIgnoringASCIICase(mimeTypeFromExtension, "audio/"_s) || startsWithLettersIgnoringASCIICase(mimeTypeFromExtension, "video/"_s);
if (isMediaType || MIMETypeRegistry::canShowNonMediaMIMEType(mimeTypeFromExtension) || mimeTypeFromContent.isEmpty())
m_response.setMimeType(WTF::move(mimeTypeFromExtension));
else
m_response.setMimeType(WTF::move(mimeTypeFromContent));
Expand Down