mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
ansi_colors: fix crash on invalid ANSI color sequence
This commit is contained in:
parent
f24c7afa69
commit
dcc227fa64
2 changed files with 9 additions and 1 deletions
|
@ -17,6 +17,7 @@
|
|||
**Fixed:**
|
||||
|
||||
* Fixed crash while converting ANSI color codes with leading zeroes
|
||||
* Fixed crash while parsing invalid ANSI color code
|
||||
|
||||
**Security:**
|
||||
|
||||
|
|
|
@ -256,7 +256,14 @@ def ansi_color_escape_code_to_name(escape_code, style, reversed_style=None):
|
|||
if reversed_style is None:
|
||||
style, reversed_style = ansi_reverse_style(style, return_style=True)
|
||||
# strip some actual escape codes, if needed.
|
||||
ec = ANSI_ESCAPE_CODE_RE.match(escape_code).group(2)
|
||||
match = ANSI_ESCAPE_CODE_RE.match(escape_code)
|
||||
if not match:
|
||||
msg = 'Invalid ANSI color sequence "{0}", using "NO_COLOR" instead.'.format(
|
||||
escape_code
|
||||
)
|
||||
warnings.warn(msg, RuntimeWarning)
|
||||
return ("NO_COLOR",)
|
||||
ec = match.group(2)
|
||||
names = []
|
||||
n_ints = 0
|
||||
seen_set_foreback = False
|
||||
|
|
Loading…
Add table
Reference in a new issue