Commit b551d400 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix Bug 415254 - [regression] HTML viewer complains about "external references...

Fix Bug 415254 - [regression] HTML viewer complains about "external references to images etc." when there are no images

FIXED-IN: 5.13.1
BUG: 415254
parent 7750e056
......@@ -66,9 +66,6 @@ void MessageViewerUtilsTest::shouldContainsExternalReferences()
QFile file(curPath + filename);
QVERIFY(file.open(QIODevice::ReadOnly));
const QString html = QString::fromLatin1(file.readAll());
QEXPECT_FAIL("noimage3.txt", "Need to Investigate it", Continue);
QEXPECT_FAIL("noimage2.txt", "Need to Investigate it", Continue);
QCOMPARE(MessageViewer::Util::containsExternalReferences(html, extraHead), hasExternalReference);
}
......
......@@ -117,11 +117,30 @@ bool Util::containsExternalReferences(const QString &str, const QString &extraHe
}
}
QRegularExpressionMatch rmatch;
const bool containsReg = str.contains(QRegularExpression(QLatin1String("<img.*src=\"?https?:/.*>"), QRegularExpression::CaseInsensitiveOption), &rmatch);
//qDebug() << " str.contains " << containsReg << rmatch.captured(0);
return containsReg;
const int startImgIndex = str.indexOf(QLatin1String("<img "));
QString newStringImg;
if (startImgIndex != -1) {
for (int i = startImgIndex, total = str.length(); i < total; ++i) {
const QChar charStr = str.at(i);
if (charStr == QLatin1Char('>')) {
newStringImg += charStr;
break;
} else {
newStringImg += charStr;
}
}
if (!newStringImg.isEmpty()) {
const bool containsReg2 = newStringImg.contains(QRegularExpression(QLatin1String("<img.*src=\"https?:/.*\".*>"), QRegularExpression::CaseInsensitiveOption), &rmatch);
if (!containsReg2) {
const bool containsReg = newStringImg.contains(QRegularExpression(QLatin1String("<img.*src=https?:/.*>"), QRegularExpression::CaseInsensitiveOption), &rmatch);
return containsReg;
} else {
return true;
}
}
}
return false;
}
bool Util::checkOverwrite(const QUrl &url, QWidget *w)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment