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

bug fix issue #1675 #1680

Merged
merged 2 commits into from
Apr 11, 2024
Merged

Conversation

NtAlexio2
Copy link
Contributor

This PR fixes issue reported on #1675. The patch decodes bytes returned from getData() by default sys.stdout encoding. The root cause of the bug is drop Python2 supporting.

@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Jan 18, 2024
@alexisbalbachan
Copy link
Contributor

Hi, the proposed solution will break on certain scenarios:

  • self.getData() can return a bytes object which may not be a valid unicode string for the selected encoding
  • Here's a specific example:
    • stdout.encoding => 'utf-8'
    • self.getData() => b'\xc3'
    • b'\xc3'.decode('utf-8') throws an exception: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 0: unexpected end of data

I think that a better approach would be to represent that buffer in an encoding agnostic way, maybe by using binascii.hexlify(self.getData())

@NtAlexio2
Copy link
Contributor Author

Thanks for your review. I applied your suggestion. Please recheck <3

@alexisbalbachan alexisbalbachan merged commit cba9632 into fortra:master Apr 11, 2024
9 checks passed
@NtAlexio2 NtAlexio2 deleted the structure-getData branch April 16, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in review This issue or pull request is being analyzed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants