Commit 69b85da0 authored by Stefano Crocco's avatar Stefano Crocco Committed by David Faure
Browse files

Don't pass application/octet-stream to OpenUrlJob

OpenUrlJob considers application/octet-stream a valid mimetype, so it
won't attempt to find out a more specific one.
parent b6558b4b
......@@ -96,7 +96,7 @@ void UrlLoader::start()
if (!m_mimeType.isEmpty()) {
if (isMimeTypeKnown(m_mimeType)) {
KService::Ptr preferredService = KApplicationTrader::preferredService(m_mimeType);
if (serviceIsKonqueror(preferredService)) {
m_request.forceAutoEmbed = true;
......@@ -244,7 +244,8 @@ bool UrlLoader::serviceIsKonqueror(KService::Ptr service)
void UrlLoader::launchOpenUrlJob(bool pauseOnMimeTypeDetermined)
m_openUrlJob = new KIO::OpenUrlJob(m_url, m_mimeType, this);
QString mimeType = isMimeTypeKnown(m_mimeType) ? m_mimeType : QString();
m_openUrlJob = new KIO::OpenUrlJob(m_url, mimeType, this);
m_openUrlJob->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, m_mainWindow));
......@@ -284,6 +285,12 @@ void UrlLoader::detectSettingsForRemoteFiles()
const QVector<QString> webengineSchemes = {"error", "konq"};
//WARNING: the use of m_mimeType.isEmpty() and not of isMimeTypeKnown(m_mimeType) in the first check
//is *intentional* and *must not* be changed. The reason is that we need
//to distinguish whether the URL loading was triggered by a download requested by WebEnginePart or not.
//In the first case, m_mimeType will never be empty, but can be unknown (application/octet-stream).
//If the loading was triggered by WebEnginePart, we can't set mimetype to text/html, because otherwise
//it would be passed back to WebEnginePart, which would lead to an endless loop
if (m_mimeType.isEmpty() && (m_url.scheme().startsWith(QStringLiteral("http")) || webengineSchemes.contains(m_url.scheme()))) {
m_mimeType = QLatin1String("text/html");
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