diff --git a/netmiko/base_connection.py b/netmiko/base_connection.py index 307223da9..e6f0b62e9 100644 --- a/netmiko/base_connection.py +++ b/netmiko/base_connection.py @@ -2344,7 +2344,7 @@ def strip_ansi_escape_codes(self, string_buffer: str) -> str: http://en.wikipedia.org/wiki/ANSI_escape_code Note: this does not capture ALL possible ANSI Escape Codes only the ones - I have encountered + that have been encountered Current codes that are filtered: ESC = '\x1b' or chr(27) @@ -2362,9 +2362,8 @@ def strip_ansi_escape_codes(self, string_buffer: str) -> str: ESC[6n Get cursor position ESC[1D Move cursor position leftward by x characters (1 in this case) ESC[9999B Move cursor down N-lines (very large value is attempt to move to the - very bottom of the screen). - - HP ProCurve and Cisco SG300 require this (possible others). + very bottom of the screen) + ESC[c Query Device (used by MikroTik in 'Safe-Mode') :param string_buffer: The string to be processed to remove ANSI escape codes :type string_buffer: str @@ -2399,6 +2398,7 @@ def strip_ansi_escape_codes(self, string_buffer: str) -> str: code_cursor_down = chr(27) + r"\[\d*B" code_wrap_around = chr(27) + r"\[\?7h" code_bracketed_paste_mode = chr(27) + r"\[\?2004h" + code_query_device = chr(27) + r"\[c" code_set = [ code_position_cursor, @@ -2429,6 +2429,7 @@ def strip_ansi_escape_codes(self, string_buffer: str) -> str: code_cursor_forward, code_wrap_around, code_bracketed_paste_mode, + code_query_device, ] output = string_buffer diff --git a/tests/unit/test_base_connection.py b/tests/unit/test_base_connection.py index 1e8b7d037..a7de4bca0 100755 --- a/tests/unit/test_base_connection.py +++ b/tests/unit/test_base_connection.py @@ -468,6 +468,7 @@ def test_strip_ansi_codes(): "\x1b[J", # code_erase_display "\x1b[0m", # code_attrs_off "\x1b[7m", # code_reverse + "\x1b[c", # code_query_device ] for ansi_code in ansi_codes_to_strip: assert connection.strip_ansi_escape_codes(ansi_code) == ""