From 4cbfb08da547f2721c207133026f451d697cce42 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Wed, 22 Jul 2020 21:27:21 -0400 Subject: [PATCH] [stable-2.10] Document existing ansi_re sequences and add `ESC[m` (#70683) (#70807) * Document existing ansi_re sequences and add `ESC[m` * Add changelog (cherry picked from commit 06a4fc2) Co-authored-by: Nathaniel Case --- changelogs/fragments/70683-terminal-ansi-re.yaml | 3 +++ lib/ansible/plugins/terminal/__init__.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/70683-terminal-ansi-re.yaml diff --git a/changelogs/fragments/70683-terminal-ansi-re.yaml b/changelogs/fragments/70683-terminal-ansi-re.yaml new file mode 100644 index 00000000000..b915c7d4bab --- /dev/null +++ b/changelogs/fragments/70683-terminal-ansi-re.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - Terminal plugins - add "\e[m" to the list of ANSI sequences stripped from device output diff --git a/lib/ansible/plugins/terminal/__init__.py b/lib/ansible/plugins/terminal/__init__.py index 23b497cfb3b..bb3ad1812f6 100644 --- a/lib/ansible/plugins/terminal/__init__.py +++ b/lib/ansible/plugins/terminal/__init__.py @@ -48,8 +48,9 @@ class TerminalBase(with_metaclass(ABCMeta, object)): #: compiled bytes regular expressions to remove ANSI codes ansi_re = [ - re.compile(br'(\x1b\[\?1h\x1b=)'), - re.compile(br'\x08.') + re.compile(br'\x1b\[\?1h\x1b='), # CSI ? 1 h ESC = + re.compile(br'\x08.'), # [Backspace] . + re.compile(br"\x1b\[m"), # ANSI reset code ] #: terminal initial prompt