Fix error when templating an unsafe string leading to a type error in Python (#82675)
Fixes #82600
This commit is contained in:
parent
1b209d742e
commit
79ea21a39f
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- template - Fix error when templating an unsafe string which corresponds to an invalid type in Python (https://github.com/ansible/ansible/issues/82600).
|
|
@ -65,7 +65,7 @@ def ansible_eval_concat(nodes):
|
|||
)
|
||||
)
|
||||
)
|
||||
except (ValueError, SyntaxError, MemoryError):
|
||||
except (TypeError, ValueError, SyntaxError, MemoryError):
|
||||
pass
|
||||
|
||||
return out
|
||||
|
@ -127,7 +127,7 @@ def ansible_native_concat(nodes):
|
|||
# parse the string ourselves without removing leading spaces/tabs.
|
||||
ast.parse(out, mode='eval')
|
||||
)
|
||||
except (ValueError, SyntaxError, MemoryError):
|
||||
except (TypeError, ValueError, SyntaxError, MemoryError):
|
||||
return out
|
||||
|
||||
if isinstance(evaled, string_types):
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
vars:
|
||||
nottemplated: this should not be seen
|
||||
imunsafe: !unsafe '{{ nottemplated }}'
|
||||
unsafe_set: !unsafe '{{ "test" }}'
|
||||
tasks:
|
||||
|
||||
- set_fact:
|
||||
|
@ -12,11 +13,15 @@
|
|||
- set_fact:
|
||||
this_always_safe: '{{ imunsafe }}'
|
||||
|
||||
- set_fact:
|
||||
this_unsafe_set: "{{ unsafe_set }}"
|
||||
|
||||
- name: ensure nothing was templated
|
||||
assert:
|
||||
that:
|
||||
- this_always_safe == imunsafe
|
||||
- imunsafe == this_was_unsafe.strip()
|
||||
- unsafe_set == this_unsafe_set.strip()
|
||||
|
||||
|
||||
- hosts: localhost
|
||||
|
|
Loading…
Reference in New Issue