File 0001-KSMTP-Fix-sending-emails-where-a-line-starts-with-a-.patch of Package ksmtp

From 0b2f9df8c809b2819d3138f04ccdc5f1f890e497 Mon Sep 17 00:00:00 2001
From: David Faure <faure@kde.org>
Date: Sun, 22 Apr 2018 11:53:28 +0200
Subject: [PATCH] KSMTP: Fix sending emails where a line starts with a dot

Summary:
My previous fix was incomplete because it only considered lines
with a single dot, and not the case where two such lines followed each
other.

BUG: 392049
FIXED-IN: 18.04

Test Plan: Updated unittest.

Reviewers: dvratil, mlaurent

Subscribers: #kde_pim

Differential Revision: https://phabricator.kde.org/D12434
---
 autotests/smtptest.cpp | 8 +++++++-
 src/sendjob.cpp        | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/autotests/smtptest.cpp b/autotests/smtptest.cpp
index a0b0a9e..c6c5617 100644
--- a/autotests/smtptest.cpp
+++ b/autotests/smtptest.cpp
@@ -213,6 +213,12 @@ void SmtpTest::testSendJob_data()
              << "C: DATA"
              << "S: 354 Ok go ahead"
              << "C: SKIP"
+             << "C: Hello world."
+             << "C: .." // Single dot becomes two
+             << "C: .." // Single dot becomes two
+             << "C: ..." // Two dots become three
+             << "C: ..Foo"  // .Foo becomes ..Foo
+             << "C: End"
              << "C: ."
              << "S: 250 Ok transfer done"
              << FakeServer::bye();
@@ -235,7 +241,7 @@ void SmtpTest::testSendJob()
     session.openAndWait();
 
     KSmtp::SendJob *send = new KSmtp::SendJob(&session);
-
+    send->setData("From: foo@bar.com\r\nTo: bar@foo.com\r\nHello world.\r\n.\r\n.\r\n..\r\n.Foo\r\nEnd");
     KMime::Message::Ptr m(new KMime::Message());
     m->from()->fromUnicodeString(QStringLiteral("Foo Bar <foo@bar.com>"), "utf-8");
     m->to()->fromUnicodeString(QStringLiteral("Bar Foo <bar@foo.com>"), "utf-8");
diff --git a/src/sendjob.cpp b/src/sendjob.cpp
index 0a46736..ca4cb10 100644
--- a/src/sendjob.cpp
+++ b/src/sendjob.cpp
@@ -111,7 +111,7 @@ void SendJob::setData(const QByteArray &data)
     d->m_data = data;
     // A line with a single dot would make SMTP think "end of message", so use two dots in that case,
     // as per https://tools.ietf.org/html/rfc5321#section-4.5.2
-    d->m_data.replace("\r\n.\r\n", "\r\n..\r\n");
+    d->m_data.replace("\r\n.", "\r\n..");
 }
 
 void SendJob::doStart()
-- 
2.16.3

openSUSE Build Service is sponsored by