forked from mirrors/gecko-dev
Bug 1656927 - Assertion failure: aContentType.Equals("image/avif"), at /builds/worker/checkouts/gecko/image/imgLoader.cpp:2785. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D85803
This commit is contained in:
parent
f468d1bd79
commit
eb0d0b2471
2 changed files with 15 additions and 2 deletions
|
|
@ -2729,6 +2729,8 @@ imgLoader::GetMIMETypeFromContent(nsIRequest* aRequest,
|
||||||
nsresult imgLoader::GetMimeTypeFromContent(const char* aContents,
|
nsresult imgLoader::GetMimeTypeFromContent(const char* aContents,
|
||||||
uint32_t aLength,
|
uint32_t aLength,
|
||||||
nsACString& aContentType) {
|
nsACString& aContentType) {
|
||||||
|
nsAutoCString detected;
|
||||||
|
|
||||||
/* Is it a GIF? */
|
/* Is it a GIF? */
|
||||||
if (aLength >= 6 &&
|
if (aLength >= 6 &&
|
||||||
(!strncmp(aContents, "GIF87a", 6) || !strncmp(aContents, "GIF89a", 6))) {
|
(!strncmp(aContents, "GIF87a", 6) || !strncmp(aContents, "GIF89a", 6))) {
|
||||||
|
|
@ -2781,8 +2783,9 @@ nsresult imgLoader::GetMimeTypeFromContent(const char* aContents,
|
||||||
aContentType.AssignLiteral(IMAGE_WEBP);
|
aContentType.AssignLiteral(IMAGE_WEBP);
|
||||||
|
|
||||||
} else if (MatchesMP4(reinterpret_cast<const uint8_t*>(aContents), aLength,
|
} else if (MatchesMP4(reinterpret_cast<const uint8_t*>(aContents), aLength,
|
||||||
aContentType)) {
|
detected) &&
|
||||||
MOZ_ASSERT(aContentType.Equals(IMAGE_AVIF));
|
detected.Equals(IMAGE_AVIF)) {
|
||||||
|
aContentType.AssignLiteral(IMAGE_AVIF);
|
||||||
} else {
|
} else {
|
||||||
/* none of the above? I give up */
|
/* none of the above? I give up */
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,16 @@ TEST_F(ImageLoader, DetectAVIFCompatibleBrand) {
|
||||||
CheckMimeType(buffer, sizeof(buffer), IMAGE_AVIF);
|
CheckMimeType(buffer, sizeof(buffer), IMAGE_AVIF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ImageLoader, DetectNonImageMP4) {
|
||||||
|
const char buffer[] =
|
||||||
|
"\x00\x00\x00\x1c" // box length
|
||||||
|
"ftyp" // box type
|
||||||
|
"isom" // major brand
|
||||||
|
"\x00\x00\x02\x00" // minor version
|
||||||
|
"isomiso2mp41"; // compatible brands
|
||||||
|
CheckMimeType(buffer, sizeof(buffer), nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ImageLoader, DetectNone) {
|
TEST_F(ImageLoader, DetectNone) {
|
||||||
const char buffer[] = "abcdefghijklmnop";
|
const char buffer[] = "abcdefghijklmnop";
|
||||||
CheckMimeType(buffer, sizeof(buffer), nullptr);
|
CheckMimeType(buffer, sizeof(buffer), nullptr);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue