mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
fix ParseAsMarkdownAndPaste corner cases (without https protocol)
This commit is contained in:
parent
30e3b5721e
commit
ebd65b26be
@ -1 +1 @@
|
||||
Subproject commit b9c3758d1d34a2281748352902cf1d3452f24bd4
|
||||
Subproject commit ace5699b65e61dfaca1e252364a8a735048e115b
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user