Commit f5adea60 authored by Volker Krause's avatar Volker Krause
Browse files

Give external extractor nodes the mimetype of their content

This ensures that extractor filter matching based on MIME types still
works, which is needed for external PDF extraction with an extractor
determined from an enclosing MIME message for example.
parent b254b056
......@@ -118,6 +118,20 @@ private Q_SLOTS:
QCOMPARE(c21.content<QString>(), QLatin1String("This is an example Aztec symbol for Wikipedia."));
QCOMPARE(c21.location().toInt(), 1);
}
void testPdfExternal()
{
ExtractorEngine engine;
engine.setUseSeparateProcess(true);
QFile f(QStringLiteral(SOURCE_DIR "/misc/test.pdf"));
QVERIFY(f.open(QFile::ReadOnly));
auto root = engine.documentNodeFactory()->createNode(f.readAll());
QVERIFY(!root.isNull());
QCOMPARE(root.mimeType(), QLatin1String("application/pdf"));
root.processor()->expandNode(root, &engine);
QCOMPARE(root.childNodes().size(), 0);
}
};
QTEST_GUILESS_MAIN(ExtractorDocumentNodeTest)
......
......@@ -152,7 +152,9 @@ ExtractorDocumentNode ExtractorDocumentNodeFactory::createNode(const QByteArray
if (d->interceptProcessor && d->interceptProcessor->canHandleData(data, fileName)) {
auto node = d->interceptProcessor->createNodeFromData(data);
if (node.mimeType().isEmpty()) {
node.setMimeType(QStringLiteral("internal/external-process"));
}
node.setProcessor(d->interceptProcessor.get());
return node;
}
......
......@@ -44,6 +44,7 @@ ExtractorDocumentNode ExternalProcessor::createNodeFromData(const QByteArray &en
{
ExtractorDocumentNode node;
node.setContent(encodedData);
node.setMimeType(QStringLiteral("application/pdf"));
return node;
}
......
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