Pectojin / duplicati-client

A command line client for controlling the Duplicati Server
GNU Lesser General Public License v2.1
75 stars 20 forks source link

Problem when importing a json file with unicode characters #17

Closed Onurtag closed 4 years ago

Onurtag commented 4 years ago

Hello. While trying to import a json file as a backup, I received the "Failed to load file as JSON" error. The problem can be reproducing by importing a json backup file with any unicode text (backup name or source folder) such as "テスト".

I tested this small change and it fixes the problem for my use case. I didn't check the full source code so there might be other places that need a similar fix.
https://github.com/Onurtag/duplicati-client/commit/f22f409f717b5bf38150f2fe719d15a095667563

Thanks for developing duplicati-client. I am using it with my small python script. Stay safe.

Pectojin commented 4 years ago

I must admit, I didn't consider what encoding io.open defaulted to when i used it. it's used 6 places in the code, so I need update all of them for consistency.

I'm in favor of using UTF-8, I just want to verify that it doesn't break interactions with existing files before i patch it.

Pectojin commented 4 years ago

It's working fine in python 3 to change all uses of open to have encoding="UTF-8", but python 2 is being difficult.

I'm looking into it a bit more, but otherwise I might just drop the python 2 compatibility and remove the compatibility code.

Pectojin commented 4 years ago

Alright, I ended up ripping out the python 2 compatibility.

The new release has encoding set as in your example: https://github.com/Pectojin/duplicati-client/releases/tag/0.5.2_beta

So both importing and exporting with your example name works correctly for me on mac, windows, and linux.

I also updated the yaml output to use UTF-8, so it even looks correct in the terminal when listing backups now (well, except on Windows where CMD seems to have no concept of how to render UTF-8, but regular text renders as usual)

Screenshot 2020-09-08 at 20 20 08