From a5df30e2bf0cc7bfc3e3d7cbadb194ec18d76e18 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Mon, 11 Jan 2021 07:22:01 +0100 Subject: [PATCH] Use _wrap_native_text only for builtin STRING_TYPE_FILTERS (#71801) (#72915) (cherry picked from commit 252685092cacdd0f8b485ed6f105ec7acc29c7a4) --- changelogs/fragments/wrap_native_text-non-collections-only.yml | 2 ++ lib/ansible/template/__init__.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/wrap_native_text-non-collections-only.yml diff --git a/changelogs/fragments/wrap_native_text-non-collections-only.yml b/changelogs/fragments/wrap_native_text-non-collections-only.yml new file mode 100644 index 00000000000..3986fa19d4d --- /dev/null +++ b/changelogs/fragments/wrap_native_text-non-collections-only.yml @@ -0,0 +1,2 @@ +bugfixes: + - Apply ``_wrap_native_text`` only for builtin filters specified in STRING_TYPE_FILTERS. diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index e1884c94612..eb1276c2896 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -510,7 +510,8 @@ class JinjaPluginIntercept(MutableMapping): for func_name, func in iteritems(method_map()): fq_name = '.'.join((parent_prefix, func_name)) # FIXME: detect/warn on intra-collection function name collisions - if USE_JINJA2_NATIVE and func_name in C.STRING_TYPE_FILTERS: + if USE_JINJA2_NATIVE and fq_name.startswith(('ansible.builtin.', 'ansible.legacy.')) and \ + func_name in C.STRING_TYPE_FILTERS: self._collection_jinja_func_cache[fq_name] = _wrap_native_text(func) else: self._collection_jinja_func_cache[fq_name] = _unroll_iterator(func)