Commit 87391c93 authored by Laurent Montel's avatar Laurent Montel 😁

Improve scam support detect when text != href (when text shows a url)

parent bc210cc6
......@@ -107,7 +107,7 @@ void ScamDetectionWebEngineTest::scamtest_data()
//Numeric value
QTest::newRow("numeric no scam") << QStringLiteral(
"<html><body><a href=\"http://baseball2.2ndhalfplays.com/nested/attribs/\">http://baseball2.2ndhalfplays.com/nested/attribs</html>")
<< false;
<< true;
QTest::newRow("numeric scam1") << QStringLiteral(
"<html><body><a href=\"http://25.15.55.88/\">test</a></body></html>") << true;
QTest::newRow("numeric scam2") << QStringLiteral(
......@@ -116,9 +116,9 @@ void ScamDetectionWebEngineTest::scamtest_data()
"<html><body><a href=\"http://1.0.1.1/\">test</a></body></html>") << true;
QTest::newRow("numeric scam4") << QStringLiteral(
"<html><body><a href=\"http://255.500.1.1/\">test</a></body></html>") << true;
QTest::newRow("numeric no scam5") << QStringLiteral(
QTest::newRow("numeric scam5") << QStringLiteral(
"<html><body><a href=\"http://baseball.2ndhalfplays.com/nested/attribs/\">http://baseball2.2ndhalfplays.com/nested/attribs</html>")
<< false;
<< true;
QTest::newRow("scam") << QStringLiteral(
"<html><body><a href=\"http://dfgdgsfdgsfdgsfd.foo.com/#contact@bla.org\">https://www.bli.com/manager/dedicated/index.html#/billing/mean</a></html>")
......
......@@ -175,6 +175,19 @@ void ScamDetectionWebEngine::handleScanPage(const QVariant &result)
foundScam = true;
}
}
if (!foundScam) {
const QString text = mapVariant.value(QStringLiteral("text")).toString();
if (!text.isEmpty()) {
if (text.startsWith(QLatin1String("http:/")) || text.startsWith(QLatin1String("https:/"))) {
if(text != href) {
d->mDetails += QLatin1String("<li>") + i18n(
"This email contains a link which reads as '%1' in the text, but actually points to '%2'. This is often the case in scam emails to mislead the recipient",
addWarningColor(text), addWarningColor(href)) + QLatin1String("</li>");
foundScam = true;
}
}
}
}
}
if (mapResult.value(QStringLiteral("forms")).toInt() > 0) {
d->mDetails += QLatin1String("<li></b>") + i18n(
......
......@@ -82,7 +82,8 @@ QString WebEngineScript::findAllAnchorsAndForms()
"for (var i = 0; i < anchors.length; ++i) {"
" out.push({"
" src: anchors[i].href,"
" title: anchors[i].title"
" title: anchors[i].title,"
" text: anchors[i].innerText"
" });"
"}"
"var forms = document.getElementsByTagName('form');"
......
Markdown is supported
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