aboutsummaryrefslogtreecommitdiffstats
path: root/src/mimeparser.h
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-14 12:45:58 +0200
committerDanilo M. <danix@danix.xyz>2026-08-14 12:45:58 +0200
commit8cf71bb617c34f52357ce0597c7d07601337828b (patch)
treea4426bd014cde0d244373435852aba806eb6d0e0 /src/mimeparser.h
parent441b93a75b9941d395edfe4b65ed0af2da9e0021 (diff)
downloadqtmaildir-8cf71bb617c34f52357ce0597c7d07601337828b.tar.gz
qtmaildir-8cf71bb617c34f52357ce0597c7d07601337828b.zip
refactor(mime): expose the Date: header parse as MimeParser::parseDate
The date search needs it and the logic already existed inside a file-local function, including the fix for Qt::RFC2822Date rejecting a string that carries a trailing timezone comment. Extracted rather than rewritten, so the second caller cannot end up without that fix.
Diffstat (limited to 'src/mimeparser.h')
-rw-r--r--src/mimeparser.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mimeparser.h b/src/mimeparser.h
index 9fceb2f..da54434 100644
--- a/src/mimeparser.h
+++ b/src/mimeparser.h
@@ -19,6 +19,7 @@
#pragma once
#include <QByteArray>
+#include <QDateTime>
#include <QHash>
#include <QList>
#include <QString>
@@ -143,4 +144,14 @@ public:
MimeParser();
ParsedMessage parse(const QString &filePath) const;
+
+ /// Parses an RFC 2822 `Date:` header, returning an invalid QDateTime when
+ /// nothing usable is there.
+ ///
+ /// **Strips comments before parsing**, because `Qt::RFC2822Date` rejects
+ /// the entire string when a trailing timezone comment is present, and
+ /// `... +0200 (CEST)` is legal per RFC 5322 and common in the wild
+ /// (verified on Qt 6.11). A parser without this silently loses the date on
+ /// a large share of real mail.
+ static QDateTime parseDate(const QString &rfc822Date);
};