From 65170bf24268620598ef0d5a19aa945af5cb22f4 Mon Sep 17 00:00:00 2001 From: facelessuser Date: Tue, 26 Jul 2016 20:28:18 -0600 Subject: Fix image titles not following spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don’t allow spaces in image links. This was also causing an issue where any text following a space was treated as a title. Ref #484. --- markdown/inlinepatterns.py | 2 +- tests/misc/image.html | 4 +++- tests/misc/image.txt | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py index dcf4ad4..6d4c969 100644 --- a/markdown/inlinepatterns.py +++ b/markdown/inlinepatterns.py @@ -130,7 +130,7 @@ LINK_RE = NOIMG + BRK + \ r'''\(\s*(<.*?>|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*?)\12\s*)?\)''' # ![alttxt](http://x.com/) or ![alttxt]() -IMAGE_LINK_RE = r'\!' + BRK + r'\s*\((<.*?>|([^")]+"[^"]*"|[^\)]*))\)' +IMAGE_LINK_RE = r'\!' + BRK + r'\s*\(\s*(<.*?>|([^"\)\s]+\s*"[^"]*"|[^\)\s]*))\s*\)' # [Google][3] REFERENCE_RE = NOIMG + BRK + r'\s?\[([^\]]*)\]' diff --git a/tests/misc/image.html b/tests/misc/image.html index aa24cef..1171e4e 100644 --- a/tests/misc/image.html +++ b/tests/misc/image.html @@ -1,3 +1,5 @@

Poster

Poster

-

Blank

\ No newline at end of file +

Blank

+

![Fail](http://humane man.jpg "The most humane man.")

+

![Fail](http://humane man.jpg)

\ No newline at end of file diff --git a/tests/misc/image.txt b/tests/misc/image.txt index 41a8cf7..3fae16a 100644 --- a/tests/misc/image.txt +++ b/tests/misc/image.txt @@ -5,4 +5,8 @@ [Poster]:http://humane_man.jpg "The most humane man." -![Blank]() \ No newline at end of file +![Blank]() + +![Fail](http://humane man.jpg "The most humane man.") + +![Fail](http://humane man.jpg) -- cgit v1.2.3