From dfbad40b182b72abb5ff2913c18a7a022b36af0c Mon Sep 17 00:00:00 2001 From: decalage2 Date: Wed, 12 Dec 2018 16:07:17 +0100 Subject: [PATCH] olevba: temporary fix for Unicode errors when colorizing the output if it contains non-ascii chararcters --- oletools/olevba.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/oletools/olevba.py b/oletools/olevba.py index a2df8f9..4d3ecff 100644 --- a/oletools/olevba.py +++ b/oletools/olevba.py @@ -3330,7 +3330,12 @@ class VBA_Parser_CLI(VBA_Parser): backspace = b'\\x08' # replace backspace by "\x08" for display vba_code_filtered = vba_code_filtered.replace(b'\x08', backspace) - vba_code_filtered = colorclass.Color(self.colorize_keywords(vba_code_filtered)) + try: + # Colorize the interesting keywords in the output: + 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') print(vba_code_filtered) for (subfilename, stream_path, form_string) in self.extract_form_strings(): print('-' * 79) -- libgit2 0.21.4