Skip to content
This repository has been archived by the owner on May 14, 2020. It is now read-only.

Encoding error while backup #35

Open
coquinpa opened this issue Mar 19, 2019 · 2 comments
Open

Encoding error while backup #35

coquinpa opened this issue Mar 19, 2019 · 2 comments
Assignees

Comments

@coquinpa
Copy link

Hello,
Good job about this helpful module.
Nevertheless, I get the error below while a backup task. (Fortigate 3000D in v6.0.2).
"UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 690830: ordinal not in range(128)".
I can see the "Config system file has been downloaded by xxxx" event on the FGT. So the problem seems occuring during the file transfert or its writing.
Thank for your help.
Regards
Patrice

@coquinpa
Copy link
Author

Hello,
I have found the error cause.
There are utf-8 characters in some security objects.
So I fixed by importing "codecs" python module and using codecs.open function in backup function as below:
file = codecs.open(data['config_parameters']['filename'], 'w', 'utf-8')
My post is only for information and it is up to you to use it.
In my case, I will tell to my security officer to not use special character and add a checking routine to prevent it.
Regards.
Patrice

@migumun
Copy link
Member

migumun commented Mar 25, 2019

Hi @coquinpa
thanks for your comments and sorry for the late reply. We haven't had much time to look into it during these days. Glad to read that you found the issue.
We will be more than happy to take it into account, actually feel free to create a PR if you want to.
Otherwise I'll incoporte the changes you propose in the next days.
If you don't mind I'll leave this open until I incorporate the fix you mention or I receive a PR with the change, whatever happens first.

Thanks!

@migumun migumun reopened this Mar 25, 2019
@migumun migumun self-assigned this Mar 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants