fix(images): fix js error when using image references

In some circumstances, on a reference style image, the last capturing
group is ignored, which causes the fucntion argument to return the number
of matches instead of a string (or undefined).
Checking if the title parameter is a string ensures that the title
parameter is actually something that was caught by the regex and not some
metadata.

Closes #585
This commit is contained in:
Estevao Soares dos Santos 2018-09-14 15:48:28 +01:00
parent 63763b136f
commit b0d475fc08
7 changed files with 5 additions and 4 deletions

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

View File

@ -61,7 +61,7 @@ showdown.subParser('makehtml.images', function (text, options, globals) {
url = url.replace(showdown.helper.regexes.asteriskDashAndColon, showdown.helper.escapeCharactersCallback);
var result = '<img src="' + url + '" alt="' + altText + '"';
if (title) {
if (title && showdown.helper.isString(title)) {
title = title
.replace(/"/g, '&quot;')
//title = showdown.helper.escapeCharacters(title, '*_', false);

View File

@ -1,3 +1 @@
[![the-image]]
[the-image]: http://example.com/foo.png
<p>[<img src="http://example.com/foo.png" alt="the-image" />]</p>

View File

@ -0,0 +1,3 @@
[![the-image]]
[the-image]: http://example.com/foo.png