Commit dfbad40b182b72abb5ff2913c18a7a022b36af0c
1 parent
ea377685
olevba: temporary fix for Unicode errors when colorizing the output if it contai…
…ns non-ascii chararcters
Showing
1 changed file
with
6 additions
and
1 deletions
oletools/olevba.py
| @@ -3330,7 +3330,12 @@ class VBA_Parser_CLI(VBA_Parser): | @@ -3330,7 +3330,12 @@ class VBA_Parser_CLI(VBA_Parser): | ||
| 3330 | backspace = b'\\x08' | 3330 | backspace = b'\\x08' |
| 3331 | # replace backspace by "\x08" for display | 3331 | # replace backspace by "\x08" for display |
| 3332 | vba_code_filtered = vba_code_filtered.replace(b'\x08', backspace) | 3332 | vba_code_filtered = vba_code_filtered.replace(b'\x08', backspace) |
| 3333 | - vba_code_filtered = colorclass.Color(self.colorize_keywords(vba_code_filtered)) | 3333 | + try: |
| 3334 | + # Colorize the interesting keywords in the output: | ||
| 3335 | + vba_code_filtered = colorclass.Color(self.colorize_keywords(vba_code_filtered)) | ||
| 3336 | + except UnicodeError: | ||
| 3337 | + # TODO better handling of Unicode | ||
| 3338 | + log.error('Unicode conversion to be fixed before colorizing the output') | ||
| 3334 | print(vba_code_filtered) | 3339 | print(vba_code_filtered) |
| 3335 | for (subfilename, stream_path, form_string) in self.extract_form_strings(): | 3340 | for (subfilename, stream_path, form_string) in self.extract_form_strings(): |
| 3336 | print('-' * 79) | 3341 | print('-' * 79) |