diff options
author | Andi Gallo <andigallo@proton.me> | 2023-05-23 01:58:48 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-23 06:02:35 +0200 |
commit | 0ad131e13de00945bc3ddbacab3990b0e228963b (patch) | |
tree | 919eff08906c9220a2d6d8b2b4359c63b807d553 | |
parent | 1bbfe4630d31ba0c00a4c12c2d35bd0fa2494e3b (diff) | |
download | serenity-0ad131e13de00945bc3ddbacab3990b0e228963b.zip |
LibGfx: Fix parsing of rgba values
Trim whitespace of the alpha component before calling
parse_first_floating_point, which doesn't handle it.
-rw-r--r-- | Userland/Libraries/LibGfx/Color.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGfx/Color.cpp b/Userland/Libraries/LibGfx/Color.cpp index a4824e199e..a599e59cd2 100644 --- a/Userland/Libraries/LibGfx/Color.cpp +++ b/Userland/Libraries/LibGfx/Color.cpp @@ -64,8 +64,9 @@ static Optional<Color> parse_rgba_color(StringView string) auto b = parts[2].to_int().value_or(256); double alpha = 0; - char const* start = parts[3].characters_without_null_termination(); - auto alpha_result = parse_first_floating_point(start, start + parts[3].length()); + auto alpha_str = parts[3].trim_whitespace(); + char const* start = alpha_str.characters_without_null_termination(); + auto alpha_result = parse_first_floating_point(start, start + alpha_str.length()); if (alpha_result.parsed_value()) alpha = alpha_result.value; |