Closed SteveAyre closed 2 years ago
Hi Steve, thanks for submitting this issue.
I haven't touched this code in a while since I'm not using it anymore.
you want to try and open a PR ? I'll do my best to help.
I'm monkey-patching a function with a different regex:
import paramiko_expect
def strip_ansi_codes(s):
return re.sub(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])', '', s)
paramiko_expect.strip_ansi_codes = strip_ansi_codes
The current code does not handle some ANSI sequences cleanly, for example ones that modify cursor position.
For example:
'\x1b[1;13r\x1b[1;1H\x1b[24;1HPress any key to continue\x1b[13;1H\x1b[?25h\x1b[24;27H\x1b[?6l\x1b[1;24r\x1b[?7l\x1b[2J\x1b[1;1H\x1b[1920;1920H\x1b[6n\x1b[1;1H'
is stripped to:
'rHHPress any key to continueH?25hH?6lr?7lH20;1920HnH'