waylan/Python-Markdown — Issue #69: crash on URLs with square brackets
Author: aaronsw
Created: 2011-12-28 17:02:56+00:00
State: open

It's not a great URL, but markdown shouldn't crash on it:

>>> markdown.markdown('[x](http://example.com])')
Traceback (most recent call last):
File "", line 1, in
File "/Users/aaronsw/Code/infohacks/jottit/code/env/lib/python2.7/site-packages/markdown/__init__.py", line 386, in markdown
return md.convert(text)
File "/Users/aaronsw/Code/infohacks/jottit/code/env/lib/python2.7/site-packages/markdown/__init__.py", line 287, in convert
newRoot = treeprocessor.run(root)
File "/Users/aaronsw/Code/infohacks/jottit/code/env/lib/python2.7/site-packages/markdown/treeprocessors.py", line 289, in run
text), child)
File "/Users/aaronsw/Code/infohacks/jottit/code/env/lib/python2.7/site-packages/markdown/treeprocessors.py", line 110, in __handleInline
data, patternIndex, startIndex)
File "/Users/aaronsw/Code/infohacks/jottit/code/env/lib/python2.7/site-packages/markdown/treeprocessors.py", line 237, in __applyPattern
node = pattern.handleMatch(match)
File "/Users/aaronsw/Code/infohacks/jottit/code/env/lib/python2.7/site-packages/markdown/inlinepatterns.py", line 288, in handleMatch
el.set("href", self.sanitize_url(self.unescape(href.strip())))
File "/Users/aaronsw/Code/infohacks/jottit/code/env/lib/python2.7/site-packages/markdown/inlinepatterns.py", line 315, in sanitize_url
scheme, netloc, path, params, query, fragment = url = urlparse(url)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urlparse.py", line 134, in urlparse
tuple = urlsplit(url, scheme, allow_fragments)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urlparse.py", line 182, in urlsplit
raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL