From 264a16d822ec0e7e6eb9ebebb77496aa0994ec70 Mon Sep 17 00:00:00 2001 From: zitterbacke Date: Wed, 17 Dec 2014 20:09:44 +0100 Subject: [PATCH] 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')) ``` --- lib/ansible/modules/network/basics/uri.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/network/basics/uri.py b/lib/ansible/modules/network/basics/uri.py index 9be0a06cdc..9929316dfd 100644 --- a/lib/ansible/modules/network/basics/uri.py +++ b/lib/ansible/modules/network/basics/uri.py @@ -304,7 +304,7 @@ def uri(module, url, dest, user, password, body, method, headers, redirects, soc r.update(resp_redir) r.update(resp) try: - return r, unicode(content.decode('unicode_escape')), dest + return r, unicode(content.decode('raw_unicode_escape')), dest except: return r, content, dest except httplib2.RedirectMissingLocation: