Fix to color normalization end tag in Telnet.

Initial fix in #1243 does not account for empty string.
Addresses a potential problem in Telnet prompt similar to IndexError in telnet.py #1306
This commit is contained in:
BlauFeuer 2017-04-17 04:29:51 -04:00 committed by Griatch
parent 154799f6e0
commit ae2c2be8a1

View file

@ -309,7 +309,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
prompt = text
if not raw:
# processing
prompt = ansi.parse_ansi(_RE_N.sub("", prompt) + ("|n" if prompt[-1] != "|" else "||n"),
prompt = ansi.parse_ansi(_RE_N.sub("", prompt) + ("||n" if prompt.endswith("|") else "|n"),
strip_ansi=nocolor, xterm256=xterm256)
if mxp:
prompt = mxp_parse(prompt)