From a3df614b0ec99015075ed7d1bfff396d80dbf890 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 2 Mar 2020 14:09:10 +0100 Subject: [PATCH 2/3] misc: prevent infinite recursion when walking lazy formdata (#39803) --- wcs/qommon/substitution.py | 7 ++++++- wcs/variables.py | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wcs/qommon/substitution.py b/wcs/qommon/substitution.py index 29174c84..4222328a 100644 --- a/wcs/qommon/substitution.py +++ b/wcs/qommon/substitution.py @@ -169,9 +169,14 @@ class CompatibilityNamesDict(dict): else: return for sub_key in sub_keys: + new_depth = depth - 1 + if not isinstance(sub_key, str): + sub_key, recurse = sub_key + if not recurse: + new_depth = min(new_depth, 3) new_base = '%s_%s' % (base, sub_key) flat_keys[new_base] = None - flatten(new_base, depth=depth - 1) + flatten(new_base, depth=new_depth) for key in self.keys(): flatten(key) diff --git a/wcs/variables.py b/wcs/variables.py index ebed6557..378540f9 100644 --- a/wcs/variables.py +++ b/wcs/variables.py @@ -212,7 +212,10 @@ class LazyFormData(LazyFormDef): for key in dir(self): if key[0] == '_' or key in blacklist: continue - yield key + if key == 'parent': + yield key, False # = recurse + else: + yield key @property def objects(self): -- 2.24.0