summaryrefslogtreecommitdiff
path: root/markdown
diff options
context:
space:
mode:
authorfacelessuser <faceless.shop@gmail.com>2015-09-04 19:45:44 -0600
committerWaylan Limberg <waylan.limberg@icloud.com>2015-12-29 17:52:38 -0500
commit33774e77db6be8b699a96de529316167bf94d7ff (patch)
treede6fb397c0e3e2fb611d8efc80dd13d5fb908bd3 /markdown
parent976eefe0ab392de6af3a0d6139a28c90c0a85423 (diff)
downloadpython-markdown-33774e77db6be8b699a96de529316167bf94d7ff.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. Conflicts: markdown/preprocessors.py
Diffstat (limited to 'markdown')
-rw-r--r--markdown/preprocessors.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/markdown/preprocessors.py b/markdown/preprocessors.py
index 75cfa3a..be1b504 100644
--- a/markdown/preprocessors.py
+++ b/markdown/preprocessors.py
@@ -177,10 +177,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
- placeholder = self.md.htmlStash.store('\n\n'.join(
- items[i:right_listindex + offset]))
- del items[i:right_listindex + offset]
+ if right_listindex <= i:
+ right_listindex = i + 1
+ placeholder = self.markdown.htmlStash.store('\n\n'.join(
+ items[i:right_listindex]))
+ del items[i:right_listindex]
items.insert(i, placeholder)
return items