diff options
author | Isaac Muse <faceless.shop@gmail.com> | 2017-01-23 09:10:20 -0700 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2017-01-23 11:10:20 -0500 |
commit | 594b25d53798c30735da5a9be19c06cc94052a16 (patch) | |
tree | 7ceae815a9b1d070e1466e634c4fb4cd2a575cce /markdown/blockprocessors.py | |
parent | 4a3d1a6bc0cb49d8a472380614b53fdd300e7512 (diff) | |
download | markdown-594b25d53798c30735da5a9be19c06cc94052a16.tar.gz markdown-594b25d53798c30735da5a9be19c06cc94052a16.tar.bz2 markdown-594b25d53798c30735da5a9be19c06cc94052a16.zip |
Fix hr recursion issue (#535)
HRProcessor tried to access a member variable after recursively calling
itself. In certain situations HRProcessor will try to access its
member variable containing its match, but it will not be the same match
that call in the stack expected. This is easily fixed by storing the
match locally *before* doing any recursive work.
Diffstat (limited to 'markdown/blockprocessors.py')
-rw-r--r-- | markdown/blockprocessors.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/markdown/blockprocessors.py b/markdown/blockprocessors.py index 870151b..a3ed977 100644 --- a/markdown/blockprocessors.py +++ b/markdown/blockprocessors.py @@ -493,15 +493,16 @@ class HRProcessor(BlockProcessor): def run(self, parent, blocks): block = blocks.pop(0) + match = self.match # Check for lines in block before hr. - prelines = block[:self.match.start()].rstrip('\n') + prelines = block[:match.start()].rstrip('\n') if prelines: # Recursively parse lines before hr so they get parsed first. self.parser.parseBlocks(parent, [prelines]) # create hr util.etree.SubElement(parent, 'hr') # check for lines in block after hr. - postlines = block[self.match.end():].lstrip('\n') + postlines = block[match.end():].lstrip('\n') if postlines: # Add lines after hr to master blocks for later parsing. blocks.insert(0, postlines) |