Commit a9c55690 authored by Volker Krause's avatar Volker Krause

Reset extraction context if there is none

So far this was "leaking" the previous context, resulting in random test
results.
parent 2522889a
......@@ -101,6 +101,9 @@ private Q_SLOTS:
contextMsg.setContent(cf.readAll());
contextMsg.parse();
m_engine.setContext(&contextMsg);
} else {
m_engine.setContext(nullptr);
m_engine.setContextDate(QDateTime({2018, 1, 1}, {0, 0}));
}
QFile inFile(inputFile);
......
......@@ -227,14 +227,19 @@ void ExtractorEnginePrivate::setContent(KMime::Content *content)
void ExtractorEnginePrivate::setContext(KMime::Content *context)
{
m_mimeContext = context;
auto dateHdr = context->header<KMime::Headers::Date>();
while (!dateHdr && context->parent()) {
context = context->parent();
dateHdr = context->header<KMime::Headers::Date>();
}
if (dateHdr) {
setContextDate(dateHdr->dateTime());
if (context) {
auto dateHdr = context->header<KMime::Headers::Date>();
while (!dateHdr && context->parent()) {
context = context->parent();
dateHdr = context->header<KMime::Headers::Date>();
}
if (dateHdr) {
setContextDate(dateHdr->dateTime());
return;
}
}
setContextDate({});
}
void ExtractorEnginePrivate::setContextDate(const QDateTime &dt)
......
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