mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:57:35 +00:00
ICC: Strip trailing nul characters from MultiLocalizedUnicodeTagData
Having those trailing nuls is invalid per spec, but it happens in practice (in already checked-in test files, no less).
This commit is contained in:
parent
dedbc17160
commit
3dd6638177
2 changed files with 19 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <LibCore/MappedFile.h>
|
||||
#include <LibGfx/ICC/BinaryWriter.h>
|
||||
#include <LibGfx/ICC/Profile.h>
|
||||
#include <LibGfx/ICC/Tags.h>
|
||||
#include <LibGfx/ICC/WellKnownProfiles.h>
|
||||
#include <LibGfx/ImageFormats/JPEGLoader.h>
|
||||
#include <LibGfx/ImageFormats/PNGLoader.h>
|
||||
|
@ -42,6 +43,17 @@ TEST_CASE(jpg)
|
|||
|
||||
auto icc_profile = MUST(Gfx::ICC::Profile::try_load_from_externally_owned_memory(icc_bytes.value()));
|
||||
EXPECT(icc_profile->is_v4());
|
||||
|
||||
icc_profile->for_each_tag([](auto tag_signature, auto tag_data) {
|
||||
if (tag_signature == Gfx::ICC::profileDescriptionTag) {
|
||||
// Required per v4 spec, but in practice even v4 files sometimes have TextDescriptionTagData descriptions. Not icc-v4.jpg, though.
|
||||
EXPECT_EQ(tag_data->type(), Gfx::ICC::MultiLocalizedUnicodeTagData::Type);
|
||||
auto& multi_localized_unicode = static_cast<Gfx::ICC::MultiLocalizedUnicodeTagData&>(*tag_data);
|
||||
EXPECT_EQ(multi_localized_unicode.records().size(), 1u);
|
||||
auto& record = multi_localized_unicode.records()[0];
|
||||
EXPECT_EQ(record.text, "sRGB built-in"sv);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
TEST_CASE(webp_extended_lossless)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue