Fix crash when 7 pound signs are written alone on a line.

The code would look for trailing pound signs and would
count all the way to the beginning and beyond, resulting
in an out of bounds exception.
This commit is contained in:
Youness Alaoui 2019-02-09 13:03:26 -05:00 committed by Curtis Gedak
parent 1ae0a77464
commit caed3e9224

View file

@ -279,7 +279,9 @@ class MarkdownTokenizer(HighlightTokenizer):
if level > 0 and level < len(text):
# Count how many pound signs are at the end of the text.
while escapedText[-trailingPoundCount -1] == "#":
# Ignore starting pound signs when calculating trailing signs
while level + trailingPoundCount < len(text) and \
escapedText[-trailingPoundCount -1] == "#":
trailingPoundCount += 1
token = Token()