mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-21 03:06:34 +01:00
Improved cookies filtering + fixed crash
Improved cookies filtering for domain mismatch and for tracking cookies, it is now fully (i hope) working and ready to use in everyday browsing. Please test it by yourself and report any issues. Also fixed crash when closing cookies manager window with "Close" in title bar or with Alt+F4
This commit is contained in:
parent
56e7e5163a
commit
4a556a4adc
@ -176,7 +176,7 @@ void QupZilla::postLaunch()
|
|||||||
aboutToShowHistoryMenu(false);
|
aboutToShowHistoryMenu(false);
|
||||||
aboutToShowBookmarksMenu();
|
aboutToShowBookmarksMenu();
|
||||||
|
|
||||||
if (m_tabWidget->count() == 0) //Something went really wrong .. add one tab
|
if (m_tabWidget->getTabBar()->normalTabsCount() <= 0) //Something went really wrong .. add one tab
|
||||||
m_tabWidget->addView(m_homepage);
|
m_tabWidget->addView(m_homepage);
|
||||||
|
|
||||||
setUpdatesEnabled(true);
|
setUpdatesEnabled(true);
|
||||||
|
@ -163,6 +163,7 @@ void AutoFillModel::post(const QNetworkRequest &request, const QByteArray &outgo
|
|||||||
//Dont save in private browsing
|
//Dont save in private browsing
|
||||||
if (mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
|
if (mApp->webSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_lastOutgoingData = outgoingData;
|
m_lastOutgoingData = outgoingData;
|
||||||
|
|
||||||
QVariant v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100));
|
QVariant v = request.attribute((QNetworkRequest::Attribute)(QNetworkRequest::User + 100));
|
||||||
|
@ -17,24 +17,24 @@
|
|||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "cookiejar.h"
|
#include "cookiejar.h"
|
||||||
#include "qupzilla.h"
|
#include "qupzilla.h"
|
||||||
#define COOKIE_DEBUG
|
//#define COOKIE_DEBUG
|
||||||
|
|
||||||
//TODO: black/white listing
|
//TODO: black/white listing
|
||||||
CookieJar::CookieJar(QupZilla* mainClass, QObject* parent) :
|
CookieJar::CookieJar(QupZilla* mainClass, QObject* parent)
|
||||||
QNetworkCookieJar(parent)
|
: QNetworkCookieJar(parent)
|
||||||
,p_QupZilla(mainClass)
|
, p_QupZilla(mainClass)
|
||||||
{
|
{
|
||||||
loadSettings();
|
|
||||||
m_activeProfil = mApp->getActiveProfilPath();
|
m_activeProfil = mApp->getActiveProfilPath();
|
||||||
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CookieJar::loadSettings()
|
void CookieJar::loadSettings()
|
||||||
{
|
{
|
||||||
QSettings settings(m_activeProfil+"settings.ini", QSettings::IniFormat);
|
QSettings settings(m_activeProfil + "settings.ini", QSettings::IniFormat);
|
||||||
settings.beginGroup("Web-Browser-Settings");
|
settings.beginGroup("Web-Browser-Settings");
|
||||||
m_allowCookies = settings.value("allowCookies",true).toBool();
|
m_allowCookies = settings.value("allowCookies", true).toBool();
|
||||||
m_allowCookiesFromDomain = settings.value("allowCookiesFromVisitedDomainOnly",false).toBool();
|
m_allowCookiesFromDomain = settings.value("allowCookiesFromVisitedDomainOnly", false).toBool();
|
||||||
m_filterTrackingCookie = settings.value("filterTrackingCookie",false).toBool();
|
m_filterTrackingCookie = settings.value("filterTrackingCookie", false).toBool();
|
||||||
m_deleteOnClose = settings.value("deleteCookiesOnClose", false).toBool();
|
m_deleteOnClose = settings.value("deleteCookiesOnClose", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,14 +52,15 @@ bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const
|
|||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
|
|
||||||
foreach (QNetworkCookie cok, newList) {
|
foreach (QNetworkCookie cok, newList) {
|
||||||
if (m_allowCookiesFromDomain && !url.toString().contains(cok.domain())) {
|
if (m_allowCookiesFromDomain && !QString("." + url.host()).contains(cok.domain().remove("www."))) {
|
||||||
#ifdef COOKIE_DEBUG
|
#ifdef COOKIE_DEBUG
|
||||||
qDebug() << "purged for domain mismatch" << cok;
|
qDebug() << "purged for domain mismatch" << cok;
|
||||||
#endif
|
#endif
|
||||||
newList.removeOne(cok);
|
newList.removeOne(cok);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (m_filterTrackingCookie && cok.expirationDate() > now.addYears(2)) {
|
|
||||||
|
if (m_filterTrackingCookie && (cok.name().startsWith("__utm") || cok.expirationDate() > now.addYears(1).addMonths(6)) ) {
|
||||||
#ifdef COOKIE_DEBUG
|
#ifdef COOKIE_DEBUG
|
||||||
qDebug() << "purged as tracking " << cok;
|
qDebug() << "purged as tracking " << cok;
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,7 +26,6 @@ CookieManager::CookieManager(QWidget* parent)
|
|||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, ui(new Ui::CookieManager)
|
, ui(new Ui::CookieManager)
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
setWindowModality(Qt::WindowModal);
|
setWindowModality(Qt::WindowModal);
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -279,6 +279,16 @@ void TabBar::pinnedTabAdded()
|
|||||||
m_pinnedTabsCount++;
|
m_pinnedTabsCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TabBar::pinnedTabsCount()
|
||||||
|
{
|
||||||
|
return m_pinnedTabsCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TabBar::normalTabsCount()
|
||||||
|
{
|
||||||
|
return count() - m_pinnedTabsCount;
|
||||||
|
}
|
||||||
|
|
||||||
void TabBar::mouseDoubleClickEvent(QMouseEvent* event)
|
void TabBar::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && tabAt(event->pos()) == -1) {
|
if (event->button() == Qt::LeftButton && tabAt(event->pos()) == -1) {
|
||||||
|
@ -44,6 +44,9 @@ public:
|
|||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
void updateVisibilityWithFullscreen(bool visible);
|
void updateVisibilityWithFullscreen(bool visible);
|
||||||
|
|
||||||
|
int pinnedTabsCount();
|
||||||
|
int normalTabsCount();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void reloadTab(int index);
|
void reloadTab(int index);
|
||||||
void stopTab(int index);
|
void stopTab(int index);
|
||||||
|
Loading…
Reference in New Issue
Block a user