Skip to content

Commit

Permalink
validate color before removing alpha values
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
geier committed Feb 14, 2024
1 parent 9de3d98 commit 2fad958
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions khal/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2fad958

Please sign in to comment.