Fixed search crashing for some nested heading combinations (9.0.3 regression)

This commit is contained in:
squidfunk 2023-01-19 21:28:19 +01:00
parent c31ef005b4
commit e7013e66a9
2 changed files with 8 additions and 8 deletions

View File

@ -421,11 +421,11 @@ class Parser(HTMLParser):
# which could also be a nested section see https://bit.ly/3IxxIJZ
if self.section.depth > len(self.context):
for section in reversed(self.data):
if section.depth and section.depth <= len(self.context):
if section.depth <= len(self.context):
# Set depth to 0 in order to denote that the current section
# is exited and must not be considered again.
self.section.depth = 0
# Set depth to infinity in order to denote that the current
# section is exited and must never be considered again.
self.section.depth = float("inf")
self.section = section
break

View File

@ -421,11 +421,11 @@ class Parser(HTMLParser):
# which could also be a nested section see https://bit.ly/3IxxIJZ
if self.section.depth > len(self.context):
for section in reversed(self.data):
if section.depth and section.depth <= len(self.context):
if section.depth <= len(self.context):
# Set depth to 0 in order to denote that the current section
# is exited and must not be considered again.
self.section.depth = 0
# Set depth to infinity in order to denote that the current
# section is exited and must never be considered again.
self.section.depth = float("inf")
self.section = section
break