From 0ad131e13de00945bc3ddbacab3990b0e228963b Mon Sep 17 00:00:00 2001 From: Andi Gallo Date: Tue, 23 May 2023 01:58:48 +0000 Subject: [PATCH] LibGfx: Fix parsing of rgba values Trim whitespace of the alpha component before calling parse_first_floating_point, which doesn't handle it. --- Userland/Libraries/LibGfx/Color.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/Color.cpp b/Userland/Libraries/LibGfx/Color.cpp index a4824e199e1..a599e59cd2d 100644 --- a/Userland/Libraries/LibGfx/Color.cpp +++ b/Userland/Libraries/LibGfx/Color.cpp @@ -64,8 +64,9 @@ static Optional 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;