mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fix uri modul for JSON-escape quotation marks
consider the following response body (content) of a REST/JSON webservice containing escaped quotation marks: ```json { "key": "\"works\"" } ``` decoding this string not as raw will lose the backslash as JSON escape. later json.loads will fail to parse. Inspired by [this thread](https://groups.google.com/forum/#!topic/ansible-project/kymtiloDme4) on the mailing list and the following python shell code: ```python import json string=r'{ "key": "\"works\"" }' json.loads(string) json.loads(string.decode('raw_unicode_escape')) json.loads(string.decode('unicode_escape')) ```
This commit is contained in:
parent
338bbf6efc
commit
264a16d822
1 changed files with 1 additions and 1 deletions
|
@ -304,7 +304,7 @@ def uri(module, url, dest, user, password, body, method, headers, redirects, soc
|
||||||
r.update(resp_redir)
|
r.update(resp_redir)
|
||||||
r.update(resp)
|
r.update(resp)
|
||||||
try:
|
try:
|
||||||
return r, unicode(content.decode('unicode_escape')), dest
|
return r, unicode(content.decode('raw_unicode_escape')), dest
|
||||||
except:
|
except:
|
||||||
return r, content, dest
|
return r, content, dest
|
||||||
except httplib2.RedirectMissingLocation:
|
except httplib2.RedirectMissingLocation:
|
||||||
|
|
Loading…
Reference in a new issue