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
pull/583/merge
Estevao Soares dos Santos 2018-09-14 15:48:28 +01:00
parent 63763b136f
commit b0d475fc08
7 changed files with 9 additions and 8 deletions

2
dist/showdown.js vendored
View File

@ -3331,7 +3331,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);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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