1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Fixing download issue introduced in last commit.

This commit is contained in:
nowrep 2012-02-11 14:19:41 +01:00
parent 14c7c08c44
commit 42d9e93363
2 changed files with 19 additions and 7 deletions

View File

@ -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") {

View File

@ -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";