diff --git a/scrapli/channel/base_channel.py b/scrapli/channel/base_channel.py index a626afd9..afcee354 100644 --- a/scrapli/channel/base_channel.py +++ b/scrapli/channel/base_channel.py @@ -16,7 +16,7 @@ rb"(" rb"([78ME])" # control cursor position rb"|" - rb"([\x07])" # BEL (Terminal bell) + rb"((\]\d).*[\x07])" # BEL (Terminal bell) rb"|" rb"(\[[{}();#=?0-9]*[A-Zhglnmsu~])" # control codes starts with `[` e.x. ESC [2;37;41m rb")", diff --git a/tests/unit/channel/test_base_channel.py b/tests/unit/channel/test_base_channel.py index f1afe1dd..7bd333d5 100644 --- a/tests/unit/channel/test_base_channel.py +++ b/tests/unit/channel/test_base_channel.py @@ -348,6 +348,11 @@ def test_process_output(base_channel): b"\x1b7c\x1b8\x1b[1C\x1b7o\x1b8\x1b[1C\x1b7n\x1b8\x1b[1C\x1b7f\x1b8\x1b[1C\x1b7i\x1b8\x1b[1C\x1b7g\x1b8\x1b[1C\x1b7u\x1b8\x1b[1C\x1b7r\x1b8\x1b[1C\x1b7e\x1b8\x1b[1C", b"configure", ), + # https://github.com/carlmontanari/scrapli/discussions/325#discussioncomment-9234132 + ( + b"\x1b[?2004h\x1b]0;user@line5-cpe-0: ~\x07user@line5-cpe-0:~$", + b"user@line5-cpe-0:~$", + ), ), ) def test_strip_ansi(base_channel, buf: bytes, expected: bytes):