From 2fad95807b48e8ef54c335a9d30534b1c52ed669 Mon Sep 17 00:00:00 2001 From: Christian Geier Date: Wed, 14 Feb 2024 15:19:10 +0100 Subject: [PATCH] validate color before removing alpha values Before we would crash if color was None or remove the leading character from colors if the lenth was 9 or 5 without it being an RGB value. --- khal/ui/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/khal/ui/__init__.py b/khal/ui/__init__.py index 72cc9dccc..930b30238 100644 --- a/khal/ui/__init__.py +++ b/khal/ui/__init__.py @@ -1324,9 +1324,9 @@ def _add_calendar_colors( # In case the color contains an alpha value, remove it for urwid. # eg '#RRGGBBAA' -> '#RRGGBB' and '#RGBA' -> '#RGB'. - if len(color) == 9: + if color and len(color) == 9 and color[0] == '#': color = color[0:7] - elif len(color) == 5: + elif color and len(color) == 5 and color[0] == '#': color = color[0:4] entry = _urwid_palette_entry(