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 stdout output #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix stdout output #25

wants to merge 2 commits into from

Conversation

x11x
Copy link

@x11x x11x commented Aug 7, 2023

Properly writes JSON output to the file, instead of writing the __repr__ of a Python bytes literal containing the JSON.

Also changes decryptBitwardenJSON to return a dictionary instead of JSON-encoded string, and adds write_json function to handle JSON-encoded output (using json.dumpinstead ofprintorTextIO.write`).

Fixes #24

Properly writes JSON output to the file, instead of writing the `__repr__` of a Python `bytes` literal containing the JSON.

Also changes `decryptBitwardenJSON` to return a dictionary instead of JSON-encoded string, and adds `write_json function to handle JSON-encoded output (using `json.dump` instead of `print` or `TextIO.write`).

Fixes GurpreetKang#24
@x11x
Copy link
Author

x11x commented Aug 7, 2023

To clarify how this handles output encoding:

This adds an --output-encoding command-line parameter to BitwardenDecrypt.py

On Windows:
- uses --output-encoding if specified
- otherwise uses PYTHONIOENCODING environment variable if specified (leaves encoding=None to let Python handle this for us)
- defaults to "utf-8" to help Windows users whose default encoding is e.g. "cp1252" which they might not have expected

On other platforms:
- uses --output-encoding if specified
- does not enforce a default (uses encoding=None to let Python use the default encoding it has determined)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Without --output option, prints a Python bytes literal instead of the raw data
1 participant