From da8d78f38410b3a9439f2fe4be01768e82d8aa8a Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Tue, 19 Dec 2023 14:57:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dansible=20=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=20{{123}}=20=E8=BF=99=E6=A0=B7=E7=9A=84=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/accounts/models/account.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/accounts/models/account.py b/apps/accounts/models/account.py index 99de5ddc0..0c6d507bc 100644 --- a/apps/accounts/models/account.py +++ b/apps/accounts/models/account.py @@ -128,13 +128,19 @@ class Account(AbsConnectivity, LabeledMixin, BaseAccount): if not isinstance(value, str): return value - value = value.replace('{{', '__TEMP_OPEN_BRACES__') \ - .replace('}}', '__TEMP_CLOSE_BRACES__') + def escape(v): + v = v.replace('{{', '__TEMP_OPEN_BRACES__') \ + .replace('}}', '__TEMP_CLOSE_BRACES__') - value = value.replace('__TEMP_OPEN_BRACES__', '{{ "{{" }}') \ - .replace('__TEMP_CLOSE_BRACES__', '{{ "}}" }}') + v = v.replace('__TEMP_OPEN_BRACES__', '{{ "{{" }}') \ + .replace('__TEMP_CLOSE_BRACES__', '{{ "}}" }}') - return value.replace('{%', '{{ "{%" }}').replace('%}', '{{ "%}" }}') + return v.replace('{%', '{{ "{%" }}').replace('%}', '{{ "%}" }}') + + if value.startswith('{{') and value.endswith('}}'): + return '{{' + escape(value[2:-2]) + '}}' + else: + return escape(value) def replace_history_model_with_mixin():