diff options
author | Toshio Kuratomi <toshio@fedoraproject.org> | 2014-12-23 12:21:23 -0800 |
---|---|---|
committer | Toshio Kuratomi <toshio@fedoraproject.org> | 2014-12-23 12:40:16 -0800 |
commit | 6bebd1ea153282dee4913aeb5fae14eb7fbbbf50 (patch) | |
tree | 8879aa279d1055c1670a38f0fa401a3fd7b80cc6 | |
parent | a887ab41de1911642b1bc529a6af954dfe182709 (diff) | |
download | ansible-handle-quoted-comma-dict-param.tar.gz |
handle backslash escapinghandle-quoted-comma-dict-param
-rw-r--r-- | lib/ansible/module_utils/basic.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index e10874fc9a..4f6bf66a15 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -946,8 +946,14 @@ class AnsibleModule(object): fields = [] field_buffer = [] in_quote = False + in_escape = False for c in value.strip(): - if not in_quote and c in ('\'', '"'): + if in_escape: + field_buffer.append(c) + in_escape = False + elif c == '\\': + in_escape = True + elif not in_quote and c in ('\'', '"'): in_quote = c elif in_quote and in_quote == c: in_quote = False @@ -962,7 +968,7 @@ class AnsibleModule(object): field = ''.join(field_buffer) if field: fields.append(field) - self.params[k] = dict([x.split("=", 1) for x in fields]) + self.params[k] = dict(x.split("=", 1) for x in fields) else: self.fail_json(msg="dictionary requested, could not parse JSON or key=value") else: |