vbe-decoder icon indicating copy to clipboard operation
vbe-decoder copied to clipboard

Update vbe-decoder.py to fix a utf-8 decoding exception if resulting VB script contains non-ascii chars

Open sfunkernw opened this issue 4 years ago • 1 comments

Pullrequest on behalf of by colleague to fix an exception with UTF8 chars in the decoded file:

user@laptop:/$ python3 vbe-decoder.py /vb-file-with-non-ascii-content.vbe
Traceback (most recent call last):
  File "vbe-decoder.py", line 103, in decode_file
    contents :str = handle.read()
  File "/usr/lib/python3.8/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdc in position 127: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "vbe-decoder.py", line 141, in <module>
    main()
  File "vbe-decoder.py", line 125, in main
    output :list = decode_files(args.files)
  File "vbe-decoder.py", line 95, in decode_files
    output.append(decode_file(file))
  File "vbe-decoder.py", line 105, in decode_file
    fatal_error(f'{e.message}')
AttributeError: 'UnicodeDecodeError' object has no attribute 'message'

Unfortunately can't provide the original vbe for confidentiality reasons.

sfunkernw avatar Aug 06 '21 10:08 sfunkernw

Same error:

❯ python3 vbe-decoder.py LOI-929901888222-pdf.vbe Traceback (most recent call last): File "/Users/vytenis/tmp/vbe-decoder/vbe-decoder.py", line 103, in decode_file contents :str = handle.read() ^^^^^^^^^^^^^ File "", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/vytenis/tmp/vbe-decoder/vbe-decoder.py", line 141, in main() File "/Users/vytenis/tmp/vbe-decoder/vbe-decoder.py", line 125, in main output :list = decode_files(args.files) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vytenis/tmp/vbe-decoder/vbe-decoder.py", line 95, in decode_files output.append(decode_file(file)) ^^^^^^^^^^^^^^^^^ File "/Users/vytenis/tmp/vbe-decoder/vbe-decoder.py", line 105, in decode_file fatal_error(f'{e.message}') ^^^^^^^^^ AttributeError: 'UnicodeDecodeError' object has no attribute 'message'

vytenisjakubauskas avatar May 30 '24 19:05 vytenisjakubauskas