Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError in VBA_Parser.analyze_macros() (can't concat bytes to s… #429

Conversation

enkelli
Copy link
Contributor

@enkelli enkelli commented Apr 12, 2019

…tr).

Similar to PR #288.

decompress_stream() yields bytes but vba_code value returned from
extract_macros() should be AFAIK string (at least all other yields return
string.

Sample that failed: 871beebb71290d040584fa7587c608b50e0d42e0f7657e10946de640ee4c3f1b

@decalage2
Copy link
Owner

OK thanks, I need to check that more in details. In the new version 0.54, we should return str depending on the Python version: bytes on Py2, unicode on Py3. The problem is, the codec should not be UTF-8, but based on the code page of the VBA project. Which we don't have in this case...

@decalage2 decalage2 self-requested a review April 12, 2019 10:40
@decalage2 decalage2 self-assigned this Apr 12, 2019
@decalage2 decalage2 added this to the oletools 0.54 milestone Apr 12, 2019
@enkelli
Copy link
Contributor Author

enkelli commented Apr 12, 2019

OK, I'm aware that this is just a hotfix for my needs (Py3). Hope this will be fixed properly in the next version :)

@decalage2
Copy link
Owner

I might use chardet in this case when we don't have the code page: https://github.com/chardet/chardet

@enkelli enkelli force-pushed the fix-olevba-type-error-concat-bytes-to-str branch from 79cddcd to 2a92116 Compare November 29, 2019 07:03
…tr).

Similar to PR decalage2#288.

`decompress_stream()` yields bytes but vba_code value returned from
`extract_macros()` should be AFAIK string in Python 3.
@enkelli enkelli force-pushed the fix-olevba-type-error-concat-bytes-to-str branch from 2a92116 to 3e9d763 Compare November 29, 2019 07:04
@enkelli
Copy link
Contributor Author

enkelli commented Dec 5, 2019

I might use chardet in this case when we don't have the code page: https://github.com/chardet/chardet

I've changed the PR implementation to use chardet :)

@decalage2
Copy link
Owner

For now I fixed the issue in a different way (see #455), so I'll close this PR. I plan to use chardet in a future release: see #628

@decalage2 decalage2 closed this Oct 4, 2020
Copy link
Owner

@decalage2 decalage2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it with a slightly different solution, see #455.

@enkelli enkelli deleted the fix-olevba-type-error-concat-bytes-to-str branch June 15, 2022 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants