[stable-2.14] URI Module find json sub type (#80745) (#80870)

* uri: fixed search for json types to include strings in the format xxx/yyy+json
(cherry picked from commit 0c7361d)

Co-authored-by: Brent Barbachem <barbacbd@dukes.jmu.edu>
pull/81019/head
Matt Martz 2 years ago committed by GitHub
parent a22c346620
commit 5e347b0439
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- uri - fix search for JSON type to include complex strings containing '+'

@ -706,7 +706,15 @@ def main():
sub_type = 'octet-stream' sub_type = 'octet-stream'
content_encoding = 'utf-8' 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 maybe_output = maybe_json or return_content or info['status'] not in status_code
if maybe_output: if maybe_output:

@ -687,6 +687,18 @@
that: that:
- result.json.json[0] == 'JSON Test Pattern pass1' - 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 - name: Make request that includes password in JSON keys
uri: uri:
url: "https://{{ httpbin_host}}/get?key-password=value-password" url: "https://{{ httpbin_host}}/get?key-password=value-password"

Loading…
Cancel
Save