@@ -300,8 +300,10 @@ def recognized(cls, blob):
300300 if isinstance (blob , Color ):
301301 return True
302302
303- valid_str = lambda s : isinstance (s , str ) and (s .strip () in _CSS_COLORS or \
304- re .match (r'#?[a-z0-9]{3,8}$' , s .strip ()) )
303+ def valid_str (s ):
304+ s = s .strip () if isinstance (s , str ) else ''
305+ return s in _CSS_COLORS or re .match (r'#?[A-Fa-f0-9]{3,8}$' , s )
306+
305307 if isinstance (blob , (tuple , list )):
306308 demoded = [b for b in blob if b not in (RGB ,HSV ,CMYK ,GREY )]
307309 if all (numlike (n ) and len (demoded )<= 5 for n in blob ):
@@ -331,7 +333,7 @@ def _parse(cls, clrstr):
331333 if clrstr in _CSS_COLORS : # handle css color names
332334 clrstr = _CSS_COLORS [clrstr ]
333335
334- if re .search (r'#?[0-9a-f ]{3,8}' , clrstr ): # rgb & rgba hex strings
336+ if re .search (r'#?[0-9a-fA-F ]{3,8}' , clrstr ): # rgb & rgba hex strings
335337 hexclr = clrstr .lstrip ('#' )
336338 if len (hexclr ) in (3 ,4 ):
337339 hexclr = "" .join (map ("" .join , zip (hexclr ,hexclr )))
0 commit comments