1
0
Fork 0

variables: fixed parsing of function parameters containing undefined variables

Fixed parsing of e.g.:
${f🅰️${var1}:${var2}}

If var1 wasn't defined it was incorrectly parsed as:
f🅰️${var1

I.e. it resulted in invalid number of parameters error, as the
called function was missing the second parameter.

Now with bot variables undefined it parses as:
f🅰️${var1}:${var2}

I.e. it resulted in correct number of parameters even with
undefined variables.

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
This commit is contained in:
Jaroslav Škarvada 2017-03-30 14:56:44 +02:00
parent f104dca756
commit bb2fe7440d
No known key found for this signature in database
GPG key ID: D8E1C00E076E840B

View file

@ -43,6 +43,6 @@ class Functions():
def expand(self, s):
if s is None:
return s
r = re.compile(r'(?<!\\)\${f:([^}]+)}')
r = re.compile(r'(?<!\\)\${f:(.*)}')
# expand functions and convert all \${f:*} to ${f:*} (unescape)
return re.sub(r'\\(\${f:[^}]+})', r'\1', r.sub(self.sub_func, s))
return re.sub(r'\\(\${f:.*})', r'\1', r.sub(self.sub_func, s))