diff options
author | Chris Adams <chris.adams@qinetic.com.au> | 2021-08-24 14:48:52 +1000 |
---|---|---|
committer | Chris Adams <chris.adams@qinetic.com.au> | 2021-08-30 17:19:26 +1000 |
commit | dfce1b87d379c554e5e360a64f3c4b4d302c8c55 (patch) | |
tree | e01bf6e5306f812beaa22ce3142638d3e182a6ef | |
parent | d484bfeac786713a26c60048d605cbf20d54b527 (diff) |
Fix bug when detecting HEADER / BODY substrings
The behavior should be equivalent to old QRegExp::lastIndexIn(str).
Without this fix, we never hit the "detach" which causes a variety
of further issues when creating the QMailMessage.
Change-Id: Ib9b91cd16e1d9cb6eeb1c255eea06ab387c2b9b4
Reviewed-by: Pekka Vuorela <pvuorela@iki.fi>
-rw-r--r-- | src/plugins/messageservices/imap/imapprotocol.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/messageservices/imap/imapprotocol.cpp b/src/plugins/messageservices/imap/imapprotocol.cpp index eeec79a0..67e44023 100644 --- a/src/plugins/messageservices/imap/imapprotocol.cpp +++ b/src/plugins/messageservices/imap/imapprotocol.cpp @@ -2465,8 +2465,9 @@ bool UidFetchState::appendLiteralData(ImapContext *c, const QString &preceding) pattern = QRegularExpression("BODY\\[\\S*\\] ", QRegularExpression::CaseInsensitiveOption); } - const QRegularExpressionMatch match = pattern.match(preceding); - int index = match.lastCapturedIndex(); + QRegularExpressionMatch match; + preceding.lastIndexOf(pattern, -1, &match); + int index = match.capturedStart(0); if (index != -1) { if ((index + match.captured(0).length()) == preceding.length()) { // Detach the retrieved data to a file we have ownership of |