From 9371852bb9f01c3263bb718655fa616c94061979 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 24 Jul 2017 13:31:07 +0200 Subject: Add WebP content sniffing code. --- image/imgLoader.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'image/imgLoader.cpp') diff --git a/image/imgLoader.cpp b/image/imgLoader.cpp index 3545c5be2..5e5ee7829 100644 --- a/image/imgLoader.cpp +++ b/image/imgLoader.cpp @@ -2558,6 +2558,11 @@ imgLoader::GetMimeTypeFromContent(const char* aContents, !memcmp(aContents, "\000\000\002\000", 4))) { aContentType.AssignLiteral(IMAGE_ICO); + // WebPs always begin with RIFF, a 32-bit length, and WEBP. + } else if (aLength >= 12 && !memcmp(aContents, "RIFF", 4) && + !memcmp(aContents + 8, "WEBP", 4)) { + aContentType.AssignLiteral(IMAGE_WEBP); + } else { /* none of the above? I give up */ return NS_ERROR_NOT_AVAILABLE; -- cgit v1.2.3