1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:24:58 +00:00

LibGfx/ICC+icc: Be lenient about invalid profile creation datetimes

Before, we used to reject profiles where the creation datetime was
invalid per spec. But invalid dates happen in practice (most commonly,
all fields set to 0). They don't affect profile conversion at all,
so be lenient about this, in exchange for slightly more wordy code
in the places that want to show the creation datetime.

Fixes a crash rendering page 2 of
https://fredrikbk.com/publications/copy-and-patch.pdf
This commit is contained in:
Nico Weber 2024-02-20 10:22:44 -05:00 committed by Andreas Kling
parent 3b7c252175
commit 0160f737e2
5 changed files with 114 additions and 53 deletions

View file

@ -324,7 +324,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
outln(" device class: {}", Gfx::ICC::device_class_name(profile->device_class()));
outln(" data color space: {}", Gfx::ICC::data_color_space_name(profile->data_color_space()));
outln(" connection space: {}", Gfx::ICC::profile_connection_space_name(profile->connection_space()));
outln("creation date and time: {}", Core::DateTime::from_timestamp(profile->creation_timestamp()));
if (auto time = profile->creation_timestamp().to_time_t(); !time.is_error()) {
// Print in friendly localtime for valid profiles.
outln("creation date and time: {}", Core::DateTime::from_timestamp(time.release_value()));
} else {
outln("creation date and time: {:04}-{:02}-{:02} {:02}:{:02}:{:02} UTC (invalid)",
profile->creation_timestamp().year, profile->creation_timestamp().month, profile->creation_timestamp().day,
profile->creation_timestamp().hours, profile->creation_timestamp().minutes, profile->creation_timestamp().seconds);
}
out_optional(" primary platform", profile->primary_platform().map([](auto platform) { return primary_platform_name(platform); }));
auto flags = profile->flags();