diff --git a/libs/vtextedit b/libs/vtextedit index b9c3758d..ace5699b 160000 --- a/libs/vtextedit +++ b/libs/vtextedit @@ -1 +1 @@ -Subproject commit b9c3758d1d34a2281748352902cf1d3452f24bd4 +Subproject commit ace5699b65e61dfaca1e252364a8a735048e115b diff --git a/src/widgets/editors/markdowneditor.cpp b/src/widgets/editors/markdowneditor.cpp index fefbfcff..937ac42d 100644 --- a/src/widgets/editors/markdowneditor.cpp +++ b/src/widgets/editors/markdowneditor.cpp @@ -997,6 +997,7 @@ void MarkdownEditor::parseToMarkdownAndPaste() void MarkdownEditor::handleHtmlToMarkdownData(quint64 p_id, TimeStamp p_timeStamp, const QString &p_text) { Q_UNUSED(p_id); + qDebug() << "htmlToMarkdownData" << p_timeStamp; if (m_timeStamp == p_timeStamp && !p_text.isEmpty()) { QString text(p_text); @@ -1048,6 +1049,8 @@ void MarkdownEditor::fetchImagesToLocalAndReplace(QString &p_text) continue; } + qDebug() << "fetching image link" << linkText; + const QString imageTitle = purifyImageTitle(regExp.cap(1).trimmed()); QString imageUrl = regExp.cap(2).trimmed(); @@ -1097,9 +1100,12 @@ void MarkdownEditor::fetchImagesToLocalAndReplace(QString &p_text) } QByteArray data = vte::Downloader::download(QUrl(imageUrl)); if (!data.isEmpty()) { - auto suffix = info.suffix(); + // Prefer the suffix from the real data. + auto suffix = ImageUtils::guessImageSuffix(data); if (suffix.isEmpty()) { - suffix = ImageUtils::guessImageSuffix(data); + suffix = info.suffix(); + } else if (info.suffix() != suffix) { + qWarning() << "guess a different suffix from image data" << info.suffix() << suffix; } tmpFile.reset(FileUtils::createTemporaryFile(suffix)); if (tmpFile->open() && tmpFile->write(data) > -1) {