Index: kioslave/http/kcookiejar/kcookiejar.cpp =================================================================== RCS file: /home/kde/kdelibs/kioslave/http/kcookiejar/kcookiejar.cpp,v retrieving revision 1.116 retrieving revision 1.117 diff -u -p -r1.116 -r1.117 --- kioslave/http/kcookiejar/kcookiejar.cpp 19 Jul 2004 10:16:22 -0000 1.116 +++ kioslave/http/kcookiejar/kcookiejar.cpp 20 Jul 2004 15:29:24 -0000 1.117 @@ -244,6 +244,14 @@ KCookieJar::KCookieJar() m_globalAdvice = KCookieDunno; m_configChanged = false; m_cookiesChanged = false; + + QString twoLevelTLD="name,ai,au,bd,bh,ck,eg,et,fk,il,in,kh,kr,mk,mt,na,np,nz,pg,pk,qa,sa,sb,sg,sv,ua,ug,uk,uy,vn,za,zw"; + QStringList countries = QStringList::split(',', twoLevelTLD); + for(QStringList::ConstIterator it = countries.begin(); + it != countries.end(); ++it) + { + m_twoLevelTLD.replace(*it, (int *) 1); + } } // @@ -528,14 +536,14 @@ static const char * parseNameValue(const } -static void stripDomain(const QString &_fqdn, QString &_domain) +void KCookieJar::stripDomain(const QString &_fqdn, QString &_domain) { QStringList domains; - KCookieJar::extractDomains(_fqdn, domains); + extractDomains(_fqdn, domains); _domain = domains[0]; } -static QString stripDomain( KHttpCookiePtr cookiePtr) +QString KCookieJar::stripDomain( KHttpCookiePtr cookiePtr) { QString domain; // We file the cookie under this domain. if (cookiePtr->domain().isEmpty()) @@ -620,6 +628,13 @@ void KCookieJar::extractDomains(const QS { if (partList.count() == 1) break; // We only have a TLD left. + + if ((partList.count() == 2) && (m_twoLevelTLD[partList[1].lower()])) + { + // This domain uses two-level TLDs in the form xxxx.yy + break; + } + if ((partList.count() == 2) && (partList[1].length() == 2)) { // If this is a TLD, we should stop. (e.g. co.uk) @@ -634,14 +649,6 @@ void KCookieJar::extractDomains(const QS break; } - // The .name domain uses ..name - // Although the TLD is striclty speaking .name, for our purpose - // it should be .name since people should not be able - // to set cookies for everyone with the same surname. - // Matches .name - if ((partList.count() == 2)&& (partList[1].lower() == L1("name"))) - break; - QString domain = partList.join(L1(".")); _domains.append('.' + domain); _domains.append(domain); Index: kioslave/http/kcookiejar/kcookiejar.h =================================================================== RCS file: /home/kde/kdelibs/kioslave/http/kcookiejar/kcookiejar.h,v retrieving revision 1.33 retrieving revision 1.34 diff -u -p -r1.33 -r1.34 --- kioslave/http/kcookiejar/kcookiejar.h 22 Nov 2003 16:50:45 -0000 1.33 +++ kioslave/http/kcookiejar/kcookiejar.h 20 Jul 2004 15:29:24 -0000 1.34 @@ -306,8 +306,8 @@ public: /** * Returns a list of domains (_domainList) relevant for this host. */ - static void extractDomains(const QString &_fqdn, - QStringList &_domainList); + void extractDomains(const QString &_fqdn, + QStringList &_domainList); static QString adviceToStr(KCookieAdvice _advice); static KCookieAdvice strToAdvice(const QString &_str); @@ -329,11 +329,15 @@ public: */ void setShowCookieDetails (bool value) { m_showCookieDetails = value; } +protected: + void stripDomain(const QString &_fqdn, QString &_domain); + QString stripDomain( KHttpCookiePtr cookiePtr); protected: QStringList m_domainList; KCookieAdvice m_globalAdvice; QDict m_cookieDomains; + QDict m_twoLevelTLD; bool m_configChanged; bool m_cookiesChanged; Index: kioslave/http/kcookiejar/kcookieserver.cpp =================================================================== RCS file: /home/kde/kdelibs/kioslave/http/kcookiejar/kcookieserver.cpp,v retrieving revision 1.50 retrieving revision 1.51 diff -u -p -r1.50 -r1.51 --- kioslave/http/kcookiejar/kcookieserver.cpp 9 Jun 2003 10:56:42 -0000 1.50 +++ kioslave/http/kcookiejar/kcookieserver.cpp 20 Jul 2004 15:29:24 -0000 1.51 @@ -131,7 +131,7 @@ bool KCookieServer::cookiesPending( cons if (!KCookieJar::parseURL(url, fqdn, path)) return false; - KCookieJar::extractDomains( fqdn, domains ); + mCookieJar->extractDomains( fqdn, domains ); for( KHttpCookie *cookie = mPendingCookies->first(); cookie != 0L; cookie = mPendingCookies->next()) @@ -557,7 +557,7 @@ KCookieServer::setDomainAdvice(QString u if (KCookieJar::parseURL(url, fqdn, dummy)) { QStringList domains; - KCookieJar::extractDomains(fqdn, domains); + mCookieJar->extractDomains(fqdn, domains); mCookieJar->setDomainAdvice(domains[0], KCookieJar::strToAdvice(advice)); } @@ -573,7 +573,7 @@ KCookieServer::getDomainAdvice(QString u if (KCookieJar::parseURL(url, fqdn, dummy)) { QStringList domains; - KCookieJar::extractDomains(fqdn, domains); + mCookieJar->extractDomains(fqdn, domains); advice = mCookieJar->getDomainAdvice(domains[0]); } return KCookieJar::adviceToStr(advice);