diff --git a/Libraries/LibGfx/ImageFormats/AVIFLoader.cpp b/Libraries/LibGfx/ImageFormats/AVIFLoader.cpp index f10030bbccc..1f68fc3c91b 100644 --- a/Libraries/LibGfx/ImageFormats/AVIFLoader.cpp +++ b/Libraries/LibGfx/ImageFormats/AVIFLoader.cpp @@ -68,6 +68,11 @@ static ErrorOr decode_avif_header(AVIFLoadingContext& context) if (context.decoder == nullptr) { return Error::from_string_literal("failed to allocate AVIF decoder"); } + + // This makes the decoder not error if an item in the file is missing the mandatory pixi property. + // Reason for this is that older versions of ImageMagick do not set this property, which leads to + // broken web content if the error is not ignored. + context.decoder->strictFlags &= ~AVIF_STRICT_PIXI_REQUIRED; } avifResult result = avifDecoderSetIOMemory(context.decoder, context.data.data(), context.data.size()); diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index f9287720d77..201553c870d 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -1067,3 +1067,9 @@ TEST_CASE(test_avif_frame_out_of_bounds) auto frame1 = TRY_OR_FAIL(plugin_decoder->frame(0)); EXPECT(plugin_decoder->frame(1).is_error()); } + +TEST_CASE(test_avif_missing_pixi_property) +{ + auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("avif/missing-pixi-property.avif"sv))); + EXPECT(Gfx::AVIFImageDecoderPlugin::sniff(file->bytes())); +} diff --git a/Tests/LibGfx/test-inputs/avif/missing-pixi-property.avif b/Tests/LibGfx/test-inputs/avif/missing-pixi-property.avif new file mode 100644 index 00000000000..0c538b1655f Binary files /dev/null and b/Tests/LibGfx/test-inputs/avif/missing-pixi-property.avif differ