From 3905df7f0357dda7862861ab160113e21fa95c9b Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 2 Mar 2020 14:09:10 +0100 Subject: [PATCH 2/2] misc: prevent infinite recursion when walking lazy formdata (#39803) --- wcs/qommon/substitution.py | 6 +++++- wcs/variables.py | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wcs/qommon/substitution.py b/wcs/qommon/substitution.py index eb601f17..50d9f426 100644 --- a/wcs/qommon/substitution.py +++ b/wcs/qommon/substitution.py @@ -166,9 +166,13 @@ class CompatibilityNamesDict(dict): else: return for sub_key in sub_keys: + recurse = True + if not isinstance(sub_key, str): + sub_key, recurse = sub_key new_base = '%s_%s' % (base, sub_key) flat_keys[new_base] = None - flatten(new_base, depth=depth - 1) + if recurse: + flatten(new_base, depth=depth - 1) for key in self.keys(): flatten(key) diff --git a/wcs/variables.py b/wcs/variables.py index e96638c8..a60b8cfb 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