summaryrefslogtreecommitdiffstats
path: root/image/imgLoader.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2017-07-24 13:31:07 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-02-03 10:05:56 +0100
commit9371852bb9f01c3263bb718655fa616c94061979 (patch)
treee883818cae40f0d53b458d1cd60ea659a69f958a /image/imgLoader.cpp
parent3e0351aa49be56434df121d9b4d9f283c422a670 (diff)
downloadUXP-9371852bb9f01c3263bb718655fa616c94061979.tar
UXP-9371852bb9f01c3263bb718655fa616c94061979.tar.gz
UXP-9371852bb9f01c3263bb718655fa616c94061979.tar.lz
UXP-9371852bb9f01c3263bb718655fa616c94061979.tar.xz
UXP-9371852bb9f01c3263bb718655fa616c94061979.zip
Add WebP content sniffing code.
Diffstat (limited to 'image/imgLoader.cpp')
-rw-r--r--image/imgLoader.cpp5
1 files changed, 5 insertions, 0 deletions
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;