From 112989da0e7306eeb405a5c52616e41c2164af24 Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Fri, 1 May 2020 14:38:18 -0400 Subject: [PATCH] Cast malformed color hex strings to black --- src/util/cast.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/cast.js b/src/util/cast.js index ab7c274c1..49c189039 100644 --- a/src/util/cast.js +++ b/src/util/cast.js @@ -93,6 +93,9 @@ class Cast { let color; if (typeof value === 'string' && value.substring(0, 1) === '#') { color = Color.hexToRgb(value); + + // If the color wasn't *actually* a hex color, cast to black + if (!color) color = {r: 0, g: 0, b: 0, a: 255}; } else { color = Color.decimalToRgb(Cast.toNumber(value)); }