FIX: Markdown handling failed on empty attribute value (#17199)

Seems to only be a problem when a markdown.it rule inserts links without a attribute value. There's no test, because it's not reproducible with the markdown rules in core.
This commit is contained in:
Gerhard Schlager 2022-06-28 21:27:15 +02:00 committed by GitHub
parent 809f3d37cd
commit 2d6ef232a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -6,8 +6,9 @@ const HTML_TYPES = ["html_block", "html_inline"];
function addImage(uploads, token) {
if (token.attrs) {
for (let i = 0; i < token.attrs.length; i++) {
if (token.attrs[i][1].indexOf("upload://") === 0) {
uploads.push({ token, srcIndex: i, origSrc: token.attrs[i][1] });
const value = token.attrs[i][1];
if (value?.startsWith("upload://")) {
uploads.push({ token, srcIndex: i, origSrc: value });
break;
}
}