diff options
author | facelessuser <faceless.shop@gmail.com> | 2015-09-04 19:45:44 -0600 |
---|---|---|
committer | facelessuser <faceless.shop@gmail.com> | 2015-09-04 19:45:44 -0600 |
commit | 6cd3765a1d60b6557b9f083b4218fe00287a9329 (patch) | |
tree | e68313e9c551b1998dfc39b7df766f310c58abd5 /markdown/preprocessors.py | |
parent | d442f575a35fdf5f7b78df7355c32c4728ff98be (diff) | |
download | python-markdown-6cd3765a1d60b6557b9f083b4218fe00287a9329.tar.gz |
Fix infinite loop #430
This should fix the remaining corner cases that can cause infinite
loops. Previous iterations did not account for scenarios where the
“end” index was less than the “start” index. If the “end” index is
ever less than or equal to the “start” index, the “end” will be
adjusted to to be “start” + 1 allow the full range to be extracted and
replaced.
Diffstat (limited to 'markdown/preprocessors.py')
-rw-r--r-- | markdown/preprocessors.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/markdown/preprocessors.py b/markdown/preprocessors.py index 7fd38d3..7ea4fcf 100644 --- a/markdown/preprocessors.py +++ b/markdown/preprocessors.py @@ -178,10 +178,11 @@ class HtmlBlockPreprocessor(Preprocessor): else: # raw html if len(items) - right_listindex <= 1: # last element right_listindex -= 1 - offset = 1 if i == right_listindex else 0 + if right_listindex <= i: + right_listindex = i + 1 placeholder = self.markdown.htmlStash.store('\n\n'.join( - items[i:right_listindex + offset])) - del items[i:right_listindex + offset] + items[i:right_listindex])) + del items[i:right_listindex] items.insert(i, placeholder) return items |