From dcad473afc016283bf12fe4e1636f0266a91513e Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Mon, 20 Mar 2023 17:55:27 +0100 Subject: Avoid redundant unsafe wrapping in ansible_eval_concat (#80143) (#80162) The wrap_var is done in do_template for all concat functions after their return. (cherry picked from commit 694f12d01b17e4aba50bda55546edada6e79b5a8) --- .../fragments/ansible_eval_concat-remove-redundant-unsafe-wrap.yml | 2 ++ lib/ansible/template/native_helpers.py | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/ansible_eval_concat-remove-redundant-unsafe-wrap.yml diff --git a/changelogs/fragments/ansible_eval_concat-remove-redundant-unsafe-wrap.yml b/changelogs/fragments/ansible_eval_concat-remove-redundant-unsafe-wrap.yml new file mode 100644 index 0000000000..50124edc6f --- /dev/null +++ b/changelogs/fragments/ansible_eval_concat-remove-redundant-unsafe-wrap.yml @@ -0,0 +1,2 @@ +bugfixes: + - "``ansible_eval_concat`` - avoid redundant unsafe wrapping of templated strings converted to Python types" diff --git a/lib/ansible/template/native_helpers.py b/lib/ansible/template/native_helpers.py index 343e10c709..3014c74507 100644 --- a/lib/ansible/template/native_helpers.py +++ b/lib/ansible/template/native_helpers.py @@ -14,7 +14,6 @@ from ansible.module_utils._text import to_text from ansible.module_utils.six import string_types from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode from ansible.utils.native_jinja import NativeJinjaText -from ansible.utils.unsafe_proxy import wrap_var _JSON_MAP = { @@ -60,7 +59,6 @@ def ansible_eval_concat(nodes): # if this looks like a dictionary, list or bool, convert it to such if out.startswith(('{', '[')) or out in ('True', 'False'): - unsafe = hasattr(out, '__UNSAFE__') try: out = ast.literal_eval( ast.fix_missing_locations( @@ -71,9 +69,6 @@ def ansible_eval_concat(nodes): ) except (ValueError, SyntaxError, MemoryError): pass - else: - if unsafe: - out = wrap_var(out) return out -- cgit v1.2.1