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 Oct 16, 2018
1 parent a48e0cf commit 980e702
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 5 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/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ showdown.subParser('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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>[<img src="http://example.com/foo.png" alt="the-image" />]</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[![the-image]]

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

0 comments on commit 980e702

Please sign in to comment.