Skip to content
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

Format response cannot deal with non utf-8 characters #21

Open
jimmelville opened this issue Jul 20, 2018 · 4 comments
Open

Format response cannot deal with non utf-8 characters #21

jimmelville opened this issue Jul 20, 2018 · 4 comments
Assignees

Comments

@jimmelville
Copy link

jimmelville commented Jul 20, 2018

The fortigate supports non utf-8 characters, suggestion to replace these when formatting response:

def formatresponse(self, res, vdom=None):
        LOG.debug("formating response")
        self.logging(res)
        # Generic way to format the return from FortiAPI
        # If vdom is global the resp is a dict of resp (even 1)
        # 1 per vdom we check only the first one here (might need a more
        # complex check)
        if vdom == "global":
            resp = json.loads(res.content.decode('utf-8', errors='replace'))[0]
            resp['vdom'] = "global"
        else:
            LOG.debug("content res: %s", res.content)
            resp = json.loads(res.content.decode('utf-8', errors='replace'))
        return resp
@thomnico thomnico self-assigned this Nov 11, 2018
@thomnico
Copy link
Contributor

It was actually a quick fix for python 3. Do you have a suggestion for solving this ?

@thomnico
Copy link
Contributor

Will a configuration parameter for utf-8 solve your issue ?

@jimmelville
Copy link
Author

jimmelville commented Dec 20, 2018 via email

@tchession
Copy link

Hello,

I have run into this issue on two different units running 5.6.7. I've created a few dozen objects using this library and now get the UTF-8 decoding errors when getting them back. I don't believe I've used any characters outside of Unicode. Adding errors='replace' to the UTF-8 decode does resolve the issue.

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

No branches or pull requests

3 participants