Commit 6acdac66 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

Narrow try/except ValueError block in RqlIOController.json()

The ValueError only concerns json.loads() call.
parent 15247c11de9d
......@@ -103,17 +103,17 @@ class RqlIOController(Controller):
match_form_params('version'))
def json(self):
contenttype = self._cw.get_header('Content-Type', raw=False)
if (contenttype.mediaType, contenttype.mediaSubtype) == ('application', 'json'): # noqa: E501
encoding = contenttype.params.get('charset', 'utf-8')
content = self._cw.content
else:
# Multipart content is usually built by
# cubicweb.multipart.parse_form_data() which encodes using
# "utf-8" by default.
encoding = 'utf-8'
content = self._cw.form['json'][1]
try:
contenttype = self._cw.get_header('Content-Type', raw=False)
if (contenttype.mediaType, contenttype.mediaSubtype) == ('application', 'json'): # noqa: E501
encoding = contenttype.params.get('charset', 'utf-8')
content = self._cw.content
else:
# Multipart content is usually built by
# cubicweb.multipart.parse_form_data() which encodes using
# "utf-8" by default.
encoding = 'utf-8'
content = self._cw.form['json'][1]
args = json.loads(content.getvalue().decode(encoding))
except ValueError as exc:
raise RemoteCallFailed(exc_message(exc, self._cw.encoding))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment