Fix crash when a filter with loop in definition is defined (#707)
Fixes #10621
This commit is contained in:
parent
b4e5bd9eb2
commit
5ef7739c60
@ -28,9 +28,11 @@ Base class for filter rules.
|
|||||||
# Standard Python modules
|
# Standard Python modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
import re
|
||||||
|
|
||||||
|
from ...errors import FilterError
|
||||||
from ...const import GRAMPS_LOCALE as glocale
|
from ...const import GRAMPS_LOCALE as glocale
|
||||||
_ = glocale.translation.gettext
|
_ = glocale.translation.gettext
|
||||||
import re
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -88,6 +90,10 @@ class Rule:
|
|||||||
self.match_substring = self.match_regex
|
self.match_substring = self.match_regex
|
||||||
self.prepare(db, user)
|
self.prepare(db, user)
|
||||||
self.nrprepare += 1
|
self.nrprepare += 1
|
||||||
|
if self.nrprepare > 20: # more references to a filter than expected
|
||||||
|
raise FilterError(_("The filter definition contains a loop."),
|
||||||
|
_("One rule references another which eventually"
|
||||||
|
" references the first."))
|
||||||
|
|
||||||
def prepare(self, db, user):
|
def prepare(self, db, user):
|
||||||
"""prepare so the rule can be executed efficiently"""
|
"""prepare so the rule can be executed efficiently"""
|
||||||
|
Loading…
Reference in New Issue
Block a user