From 37f952fc41146a91329a3458531095707f41a2a8 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 14 Jun 2018 19:02:01 +0200 Subject: [PATCH] Be a bit more robust with string assignment in procedure context --- platypush/procedure/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platypush/procedure/__init__.py b/platypush/procedure/__init__.py index 17a7e066e..8a412747a 100644 --- a/platypush/procedure/__init__.py +++ b/platypush/procedure/__init__.py @@ -214,7 +214,11 @@ class IfProcedure(Procedure): def execute(self, **context): for (k, v) in context.items(): - exec('{}={}'.format(k, v)) + try: + exec('{}={}'.format(k, v)) + except: + if isinstance(v, str): + exec('{}="{}"'.format(k, re.sub('(^|[^\\\])"', '\1\\"', v))) condition_true = eval(self.condition) response = Response()