Skip to content

Commit 76e5edb

Browse files
authored
limit colspan values to range [1, 1000] (#232)
1 parent 48724e7 commit 76e5edb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

markdownify/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,13 +735,13 @@ def convert_figcaption(self, el, text, parent_tags):
735735
def convert_td(self, el, text, parent_tags):
736736
colspan = 1
737737
if 'colspan' in el.attrs and el['colspan'].isdigit():
738-
colspan = int(el['colspan'])
738+
colspan = max(1, min(1000, int(el['colspan'])))
739739
return ' ' + text.strip().replace("\n", " ") + ' |' * colspan
740740

741741
def convert_th(self, el, text, parent_tags):
742742
colspan = 1
743743
if 'colspan' in el.attrs and el['colspan'].isdigit():
744-
colspan = int(el['colspan'])
744+
colspan = max(1, min(1000, int(el['colspan'])))
745745
return ' ' + text.strip().replace("\n", " ") + ' |' * colspan
746746

747747
def convert_tr(self, el, text, parent_tags):
@@ -762,7 +762,7 @@ def convert_tr(self, el, text, parent_tags):
762762
full_colspan = 0
763763
for cell in cells:
764764
if 'colspan' in cell.attrs and cell['colspan'].isdigit():
765-
full_colspan += int(cell["colspan"])
765+
full_colspan += max(1, min(1000, int(cell['colspan'])))
766766
else:
767767
full_colspan += 1
768768
if ((is_headrow

0 commit comments

Comments
 (0)