You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using without the --output option, it prints a Python bytes literal string containing the JSON to stdout like (truncated):
b'{\n "folders": [\n {\n "id": ...
I think print(decryptedJSON.encode("utf-8")) needs to be changed to just print(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 the print 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:
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`).
FixesGurpreetKang#24
x11x
linked a pull request
Aug 7, 2023
that will
close
this issue
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: