Skip to content

Fix stdout output#25

Open
x11x wants to merge 2 commits into
GurpreetKang:masterfrom
x11x:master
Open

Fix stdout output#25
x11x wants to merge 2 commits into
GurpreetKang:masterfrom
x11x:master

Conversation

@x11x

@x11x x11x commented Aug 7, 2023

Copy link
Copy Markdown

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

x11x commented Aug 7, 2023

Copy link
Copy Markdown
Author

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