Skip to content

Commit

Permalink
fix(images): fix js error when using image references
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tivie committed Sep 14, 2018
1 parent 63763b1 commit b0d475f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/subParsers/makehtml/images.js
Expand Up @@ -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);
Expand Down
@@ -1,3 +1 @@
[![the-image]]

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

[the-image]: http://example.com/foo.png

0 comments on commit b0d475f

Please sign in to comment.