소스 검색

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
Estevao Soares dos Santos 6 년 전
부모
커밋
b0d475fc08

+ 1 - 1
dist/showdown.js

@@ -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);

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/showdown.js.map


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/showdown.min.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/showdown.min.js.map


+ 1 - 1
src/subParsers/makehtml/images.js

@@ -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);

+ 1 - 3
test/functional/makehtml/cases/issues/#585.error-when-using-image-references.html

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

+ 3 - 0
test/functional/makehtml/cases/issues/#585.error-when-using-image-references.md

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

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.