mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-04 08:36:12 +00:00
LibWeb/MimeSniff: Add WebM signature sniffing and VINT parsing
Adds `matches_webm_signature()` and `parse_vint()` helpers per WPT spec. Uses these helpers to resolve the WebM FIXME that was in `match_an_audio_or_video_type_pattern()`.
This commit is contained in:
parent
20662f0dc9
commit
e0e513e9fc
Notes:
github-actions[bot]
2025-05-15 15:40:19 +00:00
Author: https://github.com/Prospero23 🔰
Commit: e0e513e9fc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4739
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/paaspaas00
Reviewed-by: https://github.com/stelar7
2 changed files with 164 additions and 1 deletions
|
@ -295,6 +295,34 @@ TEST_CASE(determine_computed_mime_type_when_trying_to_match_mp4_signature)
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE(determine_computed_mime_type_when_trying_to_match_webm_signature)
|
||||
{
|
||||
|
||||
HashMap<StringView, Vector<StringView>> mime_type_to_headers_map;
|
||||
|
||||
mime_type_to_headers_map.set("application/octet-stream"sv, {
|
||||
// Payload length < 4.
|
||||
"<4"sv,
|
||||
// First four bytes are not 0x1A 0x45 0xDF 0xA3.
|
||||
"\x00\x00\x00\x00"sv,
|
||||
// Correct first four bytes, but no following WebM element
|
||||
"\x1A\x45\xDF\xA3\x00\x00\x00\x00"sv,
|
||||
});
|
||||
mime_type_to_headers_map.set("video/webm"sv, {
|
||||
// Input that should parse correctly.
|
||||
"\x1A\x45\xDF\xA3\x42\x82\x84\x77\x65\x62\x6D\x00"sv,
|
||||
});
|
||||
|
||||
for (auto const& mime_type_to_headers : mime_type_to_headers_map) {
|
||||
auto mime_type = mime_type_to_headers.key;
|
||||
|
||||
for (auto const& header : mime_type_to_headers.value) {
|
||||
auto computed_mime_type = Web::MimeSniff::Resource::sniff(header.bytes(), Web::MimeSniff::SniffingConfiguration { .sniffing_context = Web::MimeSniff::SniffingContext::AudioOrVideo });
|
||||
EXPECT_EQ(mime_type, computed_mime_type.serialized());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(determine_computed_mime_type_in_a_font_context)
|
||||
{
|
||||
// Cover case where supplied type is an XML MIME type.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue