LibGfx: Fix parsing of rgba values

Trim whitespace of the alpha component before calling
parse_first_floating_point, which doesn't handle it.
This commit is contained in:
Andi Gallo 2023-05-23 01:58:48 +00:00 committed by Andreas Kling
parent 1bbfe4630d
commit 0ad131e13d
Notes: sideshowbarker 2024-07-17 02:29:45 +09:00

View file

@ -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;