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

Don't remove whitelisted cookies with "Remove all cookies on close" opt.

Closes #732
This commit is contained in:
nowrep 2013-01-30 18:49:35 +01:00
parent 20a549a837
commit bb1c775d50

View File

@ -62,7 +62,8 @@ static bool matchDomain(const QString &domain, const QString &filter)
int index = domain.indexOf(filter); int index = domain.indexOf(filter);
return (index > 0 && filter[0] == QLatin1Char('.')); return (index == 1 && domain[0] == QLatin1Char('.')) ||
(index > 0 && filter[0] == QLatin1Char('.'));
} }
static int listContainsDomain(const QStringList &list, const QString &domain) static int listContainsDomain(const QStringList &list, const QString &domain)
@ -183,10 +184,24 @@ void CookieJar::saveCookies()
QList<QNetworkCookie> allCookies; QList<QNetworkCookie> allCookies;
// If we are deleting cookies on close, let's just save empty cookie list
if (!m_deleteOnClose) { if (!m_deleteOnClose) {
// If we are deleting cookies on close, let's just save empty cookie list
allCookies = getAllCookies(); allCookies = getAllCookies();
} }
else {
// Do not delete whitelisted cookies
QList<QNetworkCookie> cookies = getAllCookies();
int count = cookies.count();
for (int i = 0; i < count; i++) {
const QNetworkCookie &cookie = cookies.at(i);
int result = listContainsDomain(m_whitelist, cookie.domain());
if (result == 1) {
allCookies.append(cookie);
}
}
}
QFile file(m_activeProfil + "cookies.dat"); QFile file(m_activeProfil + "cookies.dat");
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);