Skip to content

Commit d0b078e

Browse files
committed
Remove alpha from hexadecimal colors
We don't use those in the UI (and don't even consider them) but the spec does allow those.
1 parent 335a1fe commit d0b078e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

webapp/src/Utils/Utils.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,12 @@ public static function convertToColor(string $hex): ?string
352352
*/
353353
public static function parseHexColor(string $hex): array
354354
{
355+
// Ignore alpha in hexstrings
356+
if (strlen($hex) === 5) {
357+
$hex = substr($hex, 0, 4);
358+
} else if (strlen($hex) === 9) {
359+
$hex = substr($hex, 0, 7);
360+
}
355361
// Source: https://stackoverflow.com/a/21966100
356362
$length = (strlen($hex) - 1) / 3;
357363
$fact = [17, 1, 0.062272][$length - 1];

0 commit comments

Comments
 (0)