Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[messagingframework] Add missing slash character as protected in head…
…er parameters.
  • Loading branch information
dcaliste committed Sep 23, 2020
1 parent cd6ea7c commit 8bd77a0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
@@ -0,0 +1,53 @@
From a5191e0ebbbbf6b8f3636394f24499bd34f3fba6 Mon Sep 17 00:00:00 2001
From: Damien Caliste <dcaliste@free.fr>
Date: Wed, 2 Sep 2020 16:58:12 +0200
Subject: [PATCH] Add missing slash character as protected in header parameters

For some reason the '/' character that is defined as a protected
character in RFC2045 for values of parameters in header
Content-Type field, was missing. As a result the protocol
parameter for multipart/signed emails was not escaped which
is faulty and was confusing some email clients.

Change-Id: Id9d43b883187317ec152eea56819822612bfe307
---
src/libraries/qmfclient/qmailmessage.cpp | 3 ++-
tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/libraries/qmfclient/qmailmessage.cpp b/src/libraries/qmfclient/qmailmessage.cpp
index 71491f1a..38d1eee3 100644
--- a/src/libraries/qmfclient/qmailmessage.cpp
+++ b/src/libraries/qmfclient/qmailmessage.cpp
@@ -1956,7 +1956,8 @@ void QMailMessageHeaderFieldPrivate::setParameterEncoded(const QByteArray& name)
static QByteArray protectedParameter(const QByteArray& value)
{
QRegExp whitespace(QLatin1String("\\s+"));
- QRegExp tspecials = QRegExp(QLatin1String("[<>\\[\\]\\(\\)\\?:;@\\\\,=]"));
+ // See list in RFC2045: https://tools.ietf.org/html/rfc2045#page-12
+ QRegExp tspecials = QRegExp(QLatin1String("[<>\\[\\]\\(\\)\\?:;@\\\\,=/]"));

if ((whitespace.indexIn(value) != -1) ||
(tspecials.indexIn(value) != -1))
diff --git a/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp b/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp
index 34d8ae63..7f3f0eef 100644
--- a/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp
+++ b/tests/tst_qmailmessageheader/tst_qmailmessageheader.cpp
@@ -574,6 +574,14 @@ void tst_QMailMessageHeaderField::setParameter()
QVERIFY( header2.isParameterEncoded(name) == false );
QCOMPARE( header3.parameter(name), oversize );
QVERIFY( header3.isParameterEncoded(name) == false );
+
+ QMailMessageHeaderField header4("Content-Type: multipart/signed");
+ name = "protocol";
+ parameter = "application/pgp-signature";
+
+ header4.setParameter(name, parameter);
+ QCOMPARE( header4.toString(), QByteArray("Content-Type: multipart/signed;"
+ " protocol=\"application/pgp-signature\"") );
}

void tst_QMailMessageHeaderField::isParameterEncoded()
--
2.26.2

1 change: 1 addition & 0 deletions rpm/qmf-qt5.spec
Expand Up @@ -53,6 +53,7 @@ Patch21: 0021-Set-new-IMAP-folders-to-inherit-SynchronizationEnabl.patch
Patch22: 0022-Set-qmf-accountscheck-to-be-run-by-the-booster.patch
Patch23: 0023-Retrieve-message-lists-based-on-the-folder-sync-poli.patch
Patch24: 0024-Apply-folder-policy-to-always-on-connection.patch
Patch25: 0025-Add-missing-slash-character-as-protected-in-header-p.patch

%description
The Qt Messaging Framework, QMF, consists of a C++ library and daemon server
Expand Down

0 comments on commit 8bd77a0

Please sign in to comment.