From 8bff746d308f09ecfdfb20668ce3284561eed398 Mon Sep 17 00:00:00 2001 From: nowrep Date: Mon, 11 Mar 2013 14:42:23 +0100 Subject: [PATCH] [AdBlock] Blocking netscape plugins even without C2F enabled. Closes #791 --- CHANGELOG | 1 + src/lib/plugins/webpluginfactory.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d46856bba..899af6535 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -39,6 +39,7 @@ Version 1.4.0 * fixed sorting files case insensitively in file scheme handler * fixed possible crash in saving page screen of a really long page * fixed showing window in fullscreen with XFCE + * fixed AdBlock blocking netscape plugin even without Click2Flash * X11: fixed Ctrl+Q shortcut for DEs other than KDE and Gnome * windows: fixed color of found text when searching on page * windows: fixed navigating to file links and x: labels in file: scheme handler diff --git a/src/lib/plugins/webpluginfactory.cpp b/src/lib/plugins/webpluginfactory.cpp index de531c728..e0613da59 100644 --- a/src/lib/plugins/webpluginfactory.cpp +++ b/src/lib/plugins/webpluginfactory.cpp @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,7 +37,15 @@ QObject* WebPluginFactory::create(const QString &mimeType, const QUrl &url, cons return new QObject(); } - QString mime = mimeType.trimmed(); //Fixing bad behaviour when mimeType contains spaces + // AdBlock + AdBlockManager* manager = AdBlockManager::instance(); + QNetworkRequest request(url); + request.setAttribute(QNetworkRequest::Attribute(QNetworkRequest::User + 150), QString("object")); + if (manager->isEnabled() && manager->block(request)) { + return new QObject(); + } + + QString mime = mimeType.trimmed(); // Fixing bad behaviour when mimeType contains spaces if (mime.isEmpty()) { if (url.toString().endsWith(QLatin1String(".swf"))) { mime = "application/x-shockwave-flash"; @@ -58,14 +66,6 @@ QObject* WebPluginFactory::create(const QString &mimeType, const QUrl &url, cons return 0; } - // AdBlock - AdBlockManager* manager = AdBlockManager::instance(); - QNetworkRequest request(url); - request.setAttribute(QNetworkRequest::Attribute(QNetworkRequest::User + 150), QString("object")); - if (manager->isEnabled() && manager->block(request)) { - return new QObject(); - } - // Click2Flash whitelist QStringList whitelist = mApp->plugins()->c2f_getWhiteList(); if (whitelist.contains(url.host()) || whitelist.contains("www." + url.host()) || whitelist.contains(url.host().remove(QLatin1String("www.")))) {