Commit bfc29796 authored by Laurent Montel's avatar Laurent Montel 😁

Display warning on top of composer + fix special case

bug found by david
parent d6c6604e
......@@ -380,6 +380,16 @@ KMComposerWin::KMComposerWin(const KMime::Message::Ptr &aMsg, bool lastSignState
QVBoxLayout *vbox = new QVBoxLayout(editorAndCryptoStateIndicators);
vbox->setMargin(0);
mPotentialPhishingEmailWarning = new PotentialPhishingEmailWarning(this);
connect(mPotentialPhishingEmailWarning, &PotentialPhishingEmailWarning::sendNow, this, &KMComposerWin::slotCheckSendNowStep2);
vbox->addWidget(mPotentialPhishingEmailWarning);
mAttachmentMissing = new AttachmentMissingWarning(this);
connect(mAttachmentMissing, &AttachmentMissingWarning::attachMissingFile, this, &KMComposerWin::slotAttachMissingFile);
connect(mAttachmentMissing, &AttachmentMissingWarning::explicitClosedMissingAttachment, this, &KMComposerWin::slotExplicitClosedMissingAttachment);
vbox->addWidget(mAttachmentMissing);
KMComposerEditorNg *composerEditorNg = new KMComposerEditorNg(this, mCryptoStateIndicatorWidget);
mRichTextEditorwidget = new KPIMTextEdit::RichTextEditorWidget(composerEditorNg, mCryptoStateIndicatorWidget);
......@@ -430,14 +440,7 @@ KMComposerWin::KMComposerWin(const KMime::Message::Ptr &aMsg, bool lastSignState
mComposerBase->setAttachmentModel(attachmentModel);
mComposerBase->setAttachmentController(attachmentController);
mAttachmentMissing = new AttachmentMissingWarning(this);
connect(mAttachmentMissing, &AttachmentMissingWarning::attachMissingFile, this, &KMComposerWin::slotAttachMissingFile);
connect(mAttachmentMissing, &AttachmentMissingWarning::explicitClosedMissingAttachment, this, &KMComposerWin::slotExplicitClosedMissingAttachment);
v->addWidget(mAttachmentMissing);
mPotentialPhishingEmailWarning = new PotentialPhishingEmailWarning(this);
connect(mPotentialPhishingEmailWarning, &PotentialPhishingEmailWarning::sendNow, this, &KMComposerWin::slotCheckSendNowStep2);
v->addWidget(mPotentialPhishingEmailWarning);
if (KMailSettings::self()->showForgottenAttachmentWarning()) {
mVerifyMissingAttachment = new QTimer(this);
......
......@@ -67,6 +67,8 @@ void PotentialPhishingEmailJobTest::shouldReturnPotentialPhishingEmails_data()
QTest::newRow("WithMultiNotSameEmail") << (QStringList() << QStringLiteral("\" bla@kde.org foo@kde.org \" <foo@kde.org>")) << QStringList() << true;
QTest::newRow("EmailWithSimpleQuote") << (QStringList() << QStringLiteral("\"\'foo@kde.org\'\" <foo@kde.org>")) << QStringList() << false;
QTest::newRow("BadCompletion") << (QStringList() << QStringLiteral("@kde.org <foo@kde.org>")) << QStringList() << false;
}
void PotentialPhishingEmailJobTest::shouldReturnPotentialPhishingEmails()
......
......@@ -64,6 +64,9 @@ bool PotentialPhishingEmailJob::start()
QString tname, temail;
KEmailAddress::extractEmailAddressAndName(addr, temail, tname); // ignore return value
// which is always false
if (tname.startsWith(QLatin1Char('@'))) { //Special case when name is just @foo <...> it mustn't recognize as a valid email
continue;
}
if (tname.contains(QLatin1Char('@'))) { //Potential address
if (tname.startsWith(QLatin1Char('<')) && tname.endsWith(QLatin1Char('>'))) {
tname = tname.mid(1, tname.length() - 2);
......
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