Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: aac4f9e2bfe29202e40089c7a15080ec1400b842
https://github.com/WebKit/WebKit/commit/aac4f9e2bfe29202e40089c7a15080ec1400b842
Author: Chris Dumez <[email protected]>
Date: 2026-06-03 (Wed, 03 Jun 2026)
Changed paths:
M Source/WebCore/platform/graphics/MIMESniffer.cpp
M Tools/TestWebKitAPI/Tests/WebCore/MIMESniffer.cpp
Log Message:
-----------
MIDI and AVI MIME signatures are never matched due to typo in MIMESniffer
https://bugs.webkit.org/show_bug.cgi?id=316178
Reviewed by Jean-Yves Avenard.
The MIDI and AVI signature literals in the MIME sniffer's pattern table start
with "\0x..." rather than "\x...". The "\0" is parsed as an octal NUL escape
and the "x" is a literal character, producing 11- and 12-byte patterns that
begin with NUL+'x'+'4'+'D'+... and NUL+'x'+'5'+'2'+... instead of the
intended "MThd" and "RIFF" prefixes. The associated mask is 8 bytes (MIDI)
and 12 bytes (AVI), and since the matching loop skips any row where
mask.size() != pattern.size(), both rows are silently dropped on every
invocation. As a result, getMIMETypeFromContent() returns the empty string
for valid MIDI and AVI input.
Fix the typos by removing the leading "\0" so the patterns match their
intended bytes, and add API test coverage for both formats.
Test: Tools/TestWebKitAPI/Tests/WebCore/MIMESniffer.cpp
* Source/WebCore/platform/graphics/MIMESniffer.cpp:
(WebCore::MIMESniffer::mimeTypeFromSnifferEntries):
* Tools/TestWebKitAPI/Tests/WebCore/MIMESniffer.cpp:
(TestWebKitAPI::TEST(MIMESniffer, MIMETypes)):
Canonical link: https://commits.webkit.org/314499@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications