From 3056212dd660646a6eaa8f762ef40116c115c99b Mon Sep 17 00:00:00 2001 From: decalage2 Date: Thu, 28 Mar 2019 21:53:14 +0100 Subject: [PATCH] olevba: do not colorize the output if it is redirected to a file (issue #402) --- oletools/olevba.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/oletools/olevba.py b/oletools/olevba.py index f610790..b661128 100644 --- a/oletools/olevba.py +++ b/oletools/olevba.py @@ -3561,7 +3561,9 @@ class VBA_Parser_CLI(VBA_Parser): vba_code_filtered = vba_code_filtered.replace('\x08', backspace) try: # Colorize the interesting keywords in the output: - vba_code_filtered = colorclass.Color(self.colorize_keywords(vba_code_filtered)) + # (unless the output is redirected to a file) + if sys.stdout.isatty(): + vba_code_filtered = colorclass.Color(self.colorize_keywords(vba_code_filtered)) except UnicodeError: # TODO better handling of Unicode log.error('Unicode conversion to be fixed before colorizing the output') -- libgit2 0.21.4