diff --git a/aexpect/utils/astring.py b/aexpect/utils/astring.py index 4d4e2a9..34936ff 100644 --- a/aexpect/utils/astring.py +++ b/aexpect/utils/astring.py @@ -37,7 +37,7 @@ def strip_console_codes(output, custom_codes=None): output = f"\x1b[m{output}" console_codes = "^%[G@8]|^\\[[@A-HJ-MPXa-hl-nqrsu\\`]" console_codes += "|^\\[[\\d;]+[HJKgqnrm]|^#8|^\\([B0UK]|^\\)" - console_codes += "|^\\[\\?2004[lh]" + console_codes += "|^\\[\\?2004[lh]|^c|^\\[!p|^\\]\\d+" if custom_codes is not None and custom_codes not in console_codes: console_codes += f"|{custom_codes}" while index < len(output): diff --git a/tests/test_utils.py b/tests/test_utils.py index c3bdb18..6e9c987 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -32,6 +32,8 @@ def test_strip_console_codes(self): strip("\x1bskip-full-text")) self.assertEqual("ignores last", strip("ignores last\x1bbad")) + self.assertEqual("skips c [!p and ]104", + strip("skips\x1bc c \x1b[!p[!p and ]104\x1b]104")) self.assertRaisesRegex(ValueError, "only is not included", strip, "ignores\x1bonly\x1blast\x1bbad") self.assertRaisesRegex(ValueError, "invalid-prefix.*included", strip,