Commit 07524e43 authored by Volker Krause's avatar Volker Krause
Browse files

Use external itinerary extraction process

This avoids parsing PDF files in the KMail process, isolating us entirely
from crashes or hangs due to corrupt files or bugs in our PDF parser.

BUG: 409001
parent 3d068805
......@@ -22,15 +22,10 @@
#include "semantic_debug.h"
#include <KItinerary/ExtractorEngine>
#include <KItinerary/HtmlDocument>
#include <KItinerary/JsonLdDocument>
#include <KItinerary/PdfDocument>
#include <KPkPass/Pass>
#include <KCalendarCore/MemoryCalendar>
#include <KCalendarCore/ICalFormat>
#include <QJsonArray>
#include <QJsonDocument>
......@@ -105,28 +100,19 @@ MimeTreeParser::MessagePart::Ptr SemanticProcessor::process(MimeTreeParser::Inte
std::vector<const Extractor *> extractors;
std::unique_ptr<KPkPass::Pass> pass;
std::unique_ptr<PdfDocument> pdfDoc;
std::unique_ptr<HtmlDocument> htmlDoc;
KCalendarCore::Calendar::Ptr calendar;
ExtractorEngine engine;
engine.setUseSeparateProcess(true);
engine.setContext(part.content());
if (isPkPassContent(part.content())) {
pass.reset(KPkPass::Pass::fromData(part.content()->decodedContent()));
engine.setPass(pass.get());
} else if (part.content()->contentType()->isHTMLText()) {
htmlDoc.reset(HtmlDocument::fromData(part.content()->decodedContent()));
engine.setHtmlDocument(htmlDoc.get());
engine.setData(part.content()->decodedContent(), ExtractorInput::Html);
} else if (part.content()->contentType()->mimeType() == "application/pdf") {
pdfDoc.reset(PdfDocument::fromData(part.content()->decodedContent()));
engine.setPdfDocument(pdfDoc.get());
engine.setData(part.content()->decodedContent(), ExtractorInput::Pdf);
} else if (isCalendarContent(part.content())) {
calendar.reset(new KCalendarCore::MemoryCalendar(QTimeZone()));
KCalendarCore::ICalFormat format;
if (format.fromRawString(calendar, part.content()->decodedContent())) {
calendar->setProductId(format.loadedProductId());
engine.setCalendar(calendar);
}
engine.setData(part.content()->decodedContent(), ExtractorInput::ICal);
} else if (part.content()->contentType()->isPlainText()) {
engine.setText(part.content()->decodedText());
} else {
......
Supports Markdown
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