From 42d9e93363a9c9f4f2a605e095ad787f015faf94 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sat, 11 Feb 2012 14:19:41 +0100 Subject: [PATCH] Fixing download issue introduced in last commit. --- src/plugins/webpluginfactory.cpp | 7 ++++++- src/webview/webpage.cpp | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/plugins/webpluginfactory.cpp b/src/plugins/webpluginfactory.cpp index 52abe2f0f..5af798811 100644 --- a/src/plugins/webpluginfactory.cpp +++ b/src/plugins/webpluginfactory.cpp @@ -31,7 +31,12 @@ QObject* WebPluginFactory::create(const QString &mimeType, const QUrl &url, cons { QString mime = mimeType.trimmed(); //Fixing bad behaviour when mimeType contains spaces if (mime.isEmpty()) { - return 0; + if (url.toString().endsWith(".swf")) { + mime = "application/x-shockwave-flash"; + } + else { + return 0; + } } if (mime != "application/x-shockwave-flash") { diff --git a/src/webview/webpage.cpp b/src/webview/webpage.cpp index 9a8508cb0..ac637afa3 100644 --- a/src/webview/webpage.cpp +++ b/src/webview/webpage.cpp @@ -203,16 +203,23 @@ void WebPage::handleUnsupportedContent(QNetworkReply* reply) switch (reply->error()) { case QNetworkReply::NoError: - if (!reply->rawHeader("Content-Disposition").isEmpty()) { + if (reply->header(QNetworkRequest::ContentTypeHeader).isValid()) { + QString requestUrl = reply->request().url().toString(QUrl::RemoveFragment | QUrl::RemoveQuery); + if (requestUrl.endsWith(".swf")) { + QWebElement docElement = mainFrame()->documentElement(); + QWebElement object = docElement.findFirst(QString("object[src=\"%1\"]").arg(requestUrl)); + QWebElement embed = docElement.findFirst(QString("embed[src=\"%1\"]").arg(requestUrl)); + + if (!object.isNull() || !embed.isNull()) { + qDebug() << "WebPage::UnsupportedContent" << url << "Attempt to download flash object on site!"; + reply->deleteLater(); + return; + } + } DownloadManager* dManager = mApp->downManager(); dManager->handleUnsupportedContent(reply, this); return; } - else { - qDebug() << "WebPage::UnsupportedContent" << url << "Attempt to download request without Content-Disposition header!"; - reply->deleteLater(); - return; - } case QNetworkReply::ProtocolUnknownError: qDebug() << "WebPage::UnsupportedContent" << url << "ProtocolUnknowError";