-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Without --output option, prints a Python bytes literal instead of the raw data #24
Comments
x11x
added a commit
to x11x/BitwardenDecrypt
that referenced
this issue
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.dump` instead of `print` or `TextIO.write`). Fixes GurpreetKang#24
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using without the
--output
option, it prints a Python bytes literal string containing the JSON to stdout like (truncated):I think
print(decryptedJSON.encode("utf-8"))
needs to be changed to justprint(decryptedJSON)
(L601).It looks like you were trying to ensure output is UTF-8 encoded. I think the way to do this is calling
sys.stdout.reconfigure(encoding='utf-8')
before theprint
call. (See https://stackoverflow.com/questions/4374455/how-to-set-sys-stdout-encoding-in-python-3 for this and other ways to do this).Or, leave it up to the user to set the encoding they want (e.g. they can control this independently of your script by using the PYTHONIOENCODING environment variable, or configuring their system). In practice, this is often an issue for Windows users because the default encoding in the terminal is not always UTF-8, but on other platforms the encoding is usually set to a sane default. So you could special-case Windows and leave the
stdout
encoding as is on other platforms.The text was updated successfully, but these errors were encountered: