Commit c2942b82 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix crash when we reply to an invalid email

Bug reported by Luca Beltrame

For the moment it's a workaround until we fix it in kmime
parent b0249d3a
Pipeline #28267 failed with stage
in 34 minutes and 13 seconds
......@@ -24,6 +24,7 @@ void MessageFactoryForwardJob::start()
{
TemplateParser::TemplateParserJob *parser = new TemplateParser::TemplateParserJob(mMsg, TemplateParser::TemplateParserJob::Forward, this);
connect(parser, &TemplateParser::TemplateParserJob::parsingDone, this, &MessageFactoryForwardJob::slotParsingDone);
connect(parser, &TemplateParser::TemplateParserJob::parsingFailed, this, &MessageFactoryForwardJob::slotParsingDone);
parser->setIdentityManager(mIdentityManager);
parser->setCharsets(MessageComposerSettings::self()->preferredCharsets());
parser->setSelection(mSelection);
......
......@@ -24,6 +24,7 @@ void MessageFactoryReplyJob::start()
{
TemplateParser::TemplateParserJob *parser = new TemplateParser::TemplateParserJob(mMsg, (mReplyAll ? TemplateParser::TemplateParserJob::ReplyAll : TemplateParser::TemplateParserJob::Reply), this);
connect(parser, &TemplateParser::TemplateParserJob::parsingDone, this, &MessageFactoryReplyJob::slotReplyDone);
connect(parser, &TemplateParser::TemplateParserJob::parsingFailed, this, &MessageFactoryReplyJob::slotReplyDone);
parser->setIdentityManager(mIdentityManager);
parser->setCharsets(MessageComposerSettings::self()->preferredCharsets());
parser->setWordWrap(MessageComposerSettings::wordWrap(), MessageComposerSettings::lineWrapWidth());
......
......@@ -238,6 +238,11 @@ void TemplateParserJob::processWithTemplate(const QString &tmpl)
d->mOtp->parseObjectTree(d->mOrigMsg.data());
const auto mp = toplevelTextNode(d->mOtp->parsedPart());
if (!mp) {
qCWarning(TEMPLATEPARSER_LOG) << "Invalid message! mp is null ";
Q_EMIT parsingFailed();
return;
}
QString plainText = mp->plaintextContent();
QString htmlElement;
......
......@@ -200,6 +200,7 @@ public:
Q_SIGNALS:
void parsingDone(bool cursorPositionWasSet);
void parsingFailed();
private:
void slotExtractInfoDone(const TemplateParserExtractHtmlInfoResult &result);
......
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