diff options
author | Waylan Limberg <waylan@gmail.com> | 2014-01-09 23:43:52 -0500 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2014-01-09 23:43:52 -0500 |
commit | d0e088d535a478b9435ff49fd27583f5cb9c2641 (patch) | |
tree | ef151e966b286c1798e893d68b528763ad747de9 | |
parent | f1cb6743891ffd3f38ca0bf6a0c94210e7730361 (diff) | |
download | markdown-d0e088d535a478b9435ff49fd27583f5cb9c2641.tar.gz markdown-d0e088d535a478b9435ff49fd27583f5cb9c2641.tar.bz2 markdown-d0e088d535a478b9435ff49fd27583f5cb9c2641.zip |
No longer percent encode spaces in urls.
The current implementation was wrong as it also percent encoded query strings
(which should be plus encoded) and calling urllib.quote on the path (and
urllib.quote_plus on the query string) assumes the url is not already encoded.
What if the document author pasted a url that was already encoded? She probably
did not intend for `%20` to become `%2520`. Or did she? It is now clear to me
why many implementation do nothing to urls. Just pass them though as-is. To bad
if they are not valid HTML. HTML authors have to encodee their own urls, so I
guess markdown authors have to as well.
-rw-r--r-- | markdown/inlinepatterns.py | 1 | ||||
-rw-r--r-- | tests/basic/angle-links-and-img.html | 2 | ||||
-rw-r--r-- | tests/misc/url_spaces.html | 4 |
3 files changed, 3 insertions, 4 deletions
diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py index c0bd3d1..9335748 100644 --- a/markdown/inlinepatterns.py +++ b/markdown/inlinepatterns.py @@ -344,7 +344,6 @@ class LinkPattern(Pattern): `username:password@host:port`. """ - url = url.replace(' ', '%20') if not self.markdown.safeMode: # Return immediately bipassing parsing. return url diff --git a/tests/basic/angle-links-and-img.html b/tests/basic/angle-links-and-img.html index 255c299..1ca3b0b 100644 --- a/tests/basic/angle-links-and-img.html +++ b/tests/basic/angle-links-and-img.html @@ -1,4 +1,4 @@ -<p><a href="simple%20link" title="title">link</a> +<p><a href="simple link" title="title">link</a> <img alt="image" src="http://example.com/image.jpg" /> <a href="http://example.com/(()((())923)(">link</a> <img alt="image" src="link(()))(" /></p>
\ No newline at end of file diff --git a/tests/misc/url_spaces.html b/tests/misc/url_spaces.html index f9c91b3..ebacb75 100644 --- a/tests/misc/url_spaces.html +++ b/tests/misc/url_spaces.html @@ -1,2 +1,2 @@ -<p><a href="http://wikipedia.org/wiki/Dawn%20of%20War">Dawn of War</a></p> -<p><a href="http://wikipedia.org/wiki/Dawn%20of%20War" title="Dawn of War">Dawn of War</a></p>
\ No newline at end of file +<p><a href="http://wikipedia.org/wiki/Dawn of War">Dawn of War</a></p> +<p><a href="http://wikipedia.org/wiki/Dawn of War" title="Dawn of War">Dawn of War</a></p>
\ No newline at end of file |