diff options
author | Lee Garrett <lgarrett@rocketjump.eu> | 2023-06-16 17:03:21 +0200 |
---|---|---|
committer | Lee Garrett <lgarrett@rocketjump.eu> | 2023-06-16 19:02:22 +0200 |
commit | f34eb2d9b511aadce9e92dcf16678ada45fd632c (patch) | |
tree | 9b867847a91da7cc5eafda0e91ea9f9961ecef26 | |
parent | 1faede4c5adf9c78aa7f6d2a6898c8ee6db95b27 (diff) | |
download | debian-ansible-core-f34eb2d9b511aadce9e92dcf16678ada45fd632c.zip |
uri: fix search for json types to include strings in the format xxx/yyy+json (Closes: #1037126)
-rw-r--r-- | debian/patches/0010-fix-json-uri-subtype.patch | 63 | ||||
-rw-r--r-- | debian/patches/series | 1 |
2 files changed, 64 insertions, 0 deletions
diff --git a/debian/patches/0010-fix-json-uri-subtype.patch b/debian/patches/0010-fix-json-uri-subtype.patch new file mode 100644 index 00000000..630306bd --- /dev/null +++ b/debian/patches/0010-fix-json-uri-subtype.patch @@ -0,0 +1,63 @@ +Description: uri: fix search for json types to include strings in the format xxx/yyy+json +Author: Brent Barbachem <barbacbd@dukes.jmu.edu> +Origin: upstream, https://github.com/ansible/ansible/pull/80870 +Bug: https://github.com/ansible/ansible/issues/80709 +Forwarded: not-needed +Applied-Upstream: https://github.com/ansible/ansible/pull/80745 +Reviewed-by: Lee Garrett <debian@rocketjump.eu> +Last-Update: 2023-06-16 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +diff --git a/changelogs/fragments/update-maybe-json-uri.yml b/changelogs/fragments/update-maybe-json-uri.yml +new file mode 100644 +index 00000000000000..7cf693d2ce279b +--- /dev/null ++++ b/changelogs/fragments/update-maybe-json-uri.yml +@@ -0,0 +1,2 @@ ++bugfixes: ++- uri - fix search for JSON type to include complex strings containing '+' +diff --git a/lib/ansible/modules/uri.py b/lib/ansible/modules/uri.py +index 7919b9b2f5a0f3..9f01e1f73e0dd3 100644 +--- a/lib/ansible/modules/uri.py ++++ b/lib/ansible/modules/uri.py +@@ -706,7 +706,15 @@ def main(): + sub_type = 'octet-stream' + content_encoding = 'utf-8' + +- maybe_json = content_type and sub_type.lower() in JSON_CANDIDATES ++ if sub_type and '+' in sub_type: ++ # https://www.rfc-editor.org/rfc/rfc6839#section-3.1 ++ sub_type_suffix = sub_type.partition('+')[2] ++ maybe_json = content_type and sub_type_suffix.lower() in JSON_CANDIDATES ++ elif sub_type: ++ maybe_json = content_type and sub_type.lower() in JSON_CANDIDATES ++ else: ++ maybe_json = False ++ + maybe_output = maybe_json or return_content or info['status'] not in status_code + + if maybe_output: +diff --git a/test/integration/targets/uri/tasks/main.yml b/test/integration/targets/uri/tasks/main.yml +index 7fa687b4e7ea2a..9ba09ece7a0313 100644 +--- a/test/integration/targets/uri/tasks/main.yml ++++ b/test/integration/targets/uri/tasks/main.yml +@@ -687,6 +687,18 @@ + that: + - result.json.json[0] == 'JSON Test Pattern pass1' + ++- name: Test find JSON as subtype ++ uri: ++ url: "https://{{ httpbin_host }}/response-headers?content-type=application/ld%2Bjson" ++ method: POST ++ return_content: true ++ register: result ++ ++- name: Validate JSON as subtype ++ assert: ++ that: ++ - result.json is defined ++ + - name: Make request that includes password in JSON keys + uri: + url: "https://{{ httpbin_host}}/get?key-password=value-password" + diff --git a/debian/patches/series b/debian/patches/series index 9eedd1c6..20d747e2 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1,3 @@ 0005-use-py3.patch 0009-resolvelib_compat.patch +0010-fix-json-uri-subtype.patch |