prevent very large headline prefixes

for example: `<h9999999>` could crash the conversion.

fixes #143
This commit is contained in:
AlexVonB
2024-11-24 21:11:42 +01:00
parent fe8a821a20
commit 9595618796
2 changed files with 4 additions and 0 deletions

View File

@@ -315,6 +315,9 @@ class MarkdownConverter(object):
if convert_as_inline:
return text
# prevent MemoryErrors in case of very large n
n = max(1, min(6, n))
style = self.options['heading_style'].lower()
text = text.strip()
if style == UNDERLINED and n <= 2: