diff options
| author | Koen Kooi <koen@openembedded.org> | 2005-06-30 08:19:37 +0000 |
|---|---|---|
| committer | OpenEmbedded Project <openembedded-devel@lists.openembedded.org> | 2005-06-30 08:19:37 +0000 |
| commit | c8e5702127e507e82e6f68a4b8c546803accea9d (patch) | |
| tree | 00583491f40ecc640f2b28452af995e3a63a09d7 /packages/konqueror | |
| parent | 87ec8ca4d2e2eb4d1c1e1e1a6b46a395d56805b9 (diff) | |
import clean BK tree at cset 1.3670
Diffstat (limited to 'packages/konqueror')
14 files changed, 6066 insertions, 0 deletions
diff --git a/packages/konqueror/.mtn2git_empty b/packages/konqueror/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/konqueror/.mtn2git_empty diff --git a/packages/konqueror/konqueror-embedded-20030705/.mtn2git_empty b/packages/konqueror/konqueror-embedded-20030705/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/konqueror/konqueror-embedded-20030705/.mtn2git_empty diff --git a/packages/konqueror/konqueror-embedded-20030705/flashpart.patch b/packages/konqueror/konqueror-embedded-20030705/flashpart.patch index e69de29bb2..d1bef8043f 100644 --- a/packages/konqueror/konqueror-embedded-20030705/flashpart.patch +++ b/packages/konqueror/konqueror-embedded-20030705/flashpart.patch @@ -0,0 +1,10 @@ +diff -ur konqe.old/konq-embed/add-ons/kflashpart/flashlib/Makefile.am konqueror-embedded-snapshot-20030705/konq-embed/add-ons/kflashpart/flashlib/Makefile.am +--- konqe.old/konq-embed/add-ons/kflashpart/flashlib/Makefile.am 2003-05-29 17:08:45.000000000 +0200 ++++ konqueror-embedded-snapshot-20030705/konq-embed/add-ons/kflashpart/flashlib/Makefile.am 2004-08-22 21:40:24.000000000 +0200 +@@ -1,5 +1,6 @@ + # Comment out the following line if you use egcs : + CXXFLAGS=-O3 -Wall -fno-rtti -fno-exceptions -DDISABLE_NONQIMAGE_DEPTHS ++INCLUDES = $(QTOPIA_INCLUDES) $(all_includes) + + noinst_LTLIBRARIES = libflash.la + diff --git a/packages/konqueror/konqueror-embedded-20030705/include_qconfig.patch b/packages/konqueror/konqueror-embedded-20030705/include_qconfig.patch index e69de29bb2..245d031863 100644 --- a/packages/konqueror/konqueror-embedded-20030705/include_qconfig.patch +++ b/packages/konqueror/konqueror-embedded-20030705/include_qconfig.patch @@ -0,0 +1,14 @@ +We need to have the defines available before +we try to evaluate them + + + +--- konqueror-embedded-snapshot-20030705/konq-embed/src/popuphandler.cc~ 2002-12-05 13:47:07.000000000 +0100 ++++ konqueror-embedded-snapshot-20030705/konq-embed/src/popuphandler.cc 2004-08-22 17:10:44.000000000 +0200 +@@ -1,3 +1,6 @@ ++ ++#include <qnamespace.h> ++ + #include "popuphandler.h" + + #if defined(_WS_QWS_) && defined(QT_NO_QWS_CURSOR) diff --git a/packages/konqueror/konqueror-embedded-20030705/kcookiejar-merge.patch b/packages/konqueror/konqueror-embedded-20030705/kcookiejar-merge.patch index e69de29bb2..d5c1a9a8e5 100644 --- a/packages/konqueror/konqueror-embedded-20030705/kcookiejar-merge.patch +++ b/packages/konqueror/konqueror-embedded-20030705/kcookiejar-merge.patch @@ -0,0 +1,2924 @@ + +# +# Patch managed by http://www.holgerschurig.de/patcher.html +# + +--- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiejar.cpp~kcookiejar-merge.patch ++++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiejar.cpp +@@ -1,8 +1,8 @@ + /* This file is part of the KDE File Manager + +- Copyright (C) 1998,1999,2000,2001 Waldo Bastian (bastian@kde.org) +- Copyright (C) 2000,2001 Dawit Alemayehu (adawit@kde.org) +- ++ Copyright (C) 1998-2000 Waldo Bastian (bastian@kde.org) ++ Copyright (C) 2000,2001 Dawit Alemayehu (adawit@kde.org) ++ + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights +@@ -22,17 +22,18 @@ + */ + //---------------------------------------------------------------------------- + // +-// KDE HTTP Cookie Manager +-// $Id: kcookiejar.cpp,v 1.58.2.5 2001/11/04 04:21:39 adawit Exp $ ++// KDE File Manager -- HTTP Cookies ++// $Id: kcookiejar.cpp,v 1.117 2004/07/20 15:29:24 waba Exp $ + + // + // The cookie protocol is a mess. RFC2109 is a joke since nobody seems to +-// use it. Apart from that it is badly written. We try to implement Netscape +-// Cookies and try to behave according to RFC2109 as much as we can. ++// use it. Apart from that it is badly written. ++// We try to implement Netscape Cookies and try to behave us according to ++// RFC2109 as much as we can. ++// ++// We assume cookies do not contain any spaces (Netscape spec.) ++// According to RFC2109 this is allowed though. + // +-// We assume cookies do not contain any spaces (Netscape spec.) According to +-// RFC2109 this is allowed though. +- + + #include <config.h> + #include <sys/types.h> +@@ -44,12 +45,23 @@ + #include <unistd.h> + #include <stdio.h> + #include <string.h> ++ ++#ifdef USE_SOLARIS ++#include <strings.h> ++#endif ++ + #include <stdlib.h> + ++//#include <netinet/in.h> ++//#include <arpa/inet.h> ++ + #include <qstring.h> + #include <qstrlist.h> + #include <qlist.h> + #include <qdict.h> ++#include <qfile.h> ++#include <qdir.h> ++#include <qregexp.h> + + #include <kurl.h> + #include <krfcdate.h> +@@ -61,6 +73,13 @@ + + #define READ_BUFFER_SIZE 8192 + ++// Note with respect to QString::fromLatin1( ) ++// Cookies are stored as 8 bit data and passed to kio_http as ++// latin1 regardless of their actual encoding. ++ ++// L1 is used to indicate latin1 constants ++#define L1(x) QString::fromLatin1(x) ++ + template class QList<KHttpCookie>; + template class QDict<KHttpCookieList>; + +@@ -68,10 +87,10 @@ + { + switch( _advice ) + { +- case KCookieAccept: return "Accept"; +- case KCookieReject: return "Reject"; +- case KCookieAsk: return "Ask"; +- default: return "Dunno"; ++ case KCookieAccept: return L1("Accept"); ++ case KCookieReject: return L1("Reject"); ++ case KCookieAsk: return L1("Ask"); ++ default: return L1("Dunno"); + } + } + +@@ -80,7 +99,7 @@ + if (_str.isEmpty()) + return KCookieDunno; + +- QString advice = _str.lower(); ++ QCString advice = _str.lower().latin1(); + + if (advice == "accept") + return KCookieAccept; +@@ -105,17 +124,20 @@ + const QString &_value, + time_t _expireDate, + int _protocolVersion, +- bool _secure) : ++ bool _secure, ++ bool _httpOnly, ++ bool _explicitPath) : + mHost(_host), + mDomain(_domain), +- mPath(_path), ++ mPath(_path.isEmpty() ? QString::null : _path), + mName(_name), + mValue(_value), + mExpireDate(_expireDate), + mProtocolVersion(_protocolVersion), +- mSecure(_secure) ++ mSecure(_secure), ++ mHttpOnly(_httpOnly), ++ mExplicitPath(_explicitPath) + { +- nextCookie = 0; + } + + // +@@ -135,16 +157,17 @@ + + if (useDOMFormat || (mProtocolVersion == 0)) + { +- result = mName + "=" + mValue; ++ if ( !mName.isEmpty() ) ++ result = mName + '='; ++ result += mValue; + } + else + { +- result.sprintf("$Version=\"%d\"; ", mProtocolVersion); +- result += mName + "=\"" + mValue + "\""; +- if (!mPath.isEmpty()) +- result += "; $Path=\""+ mPath + "\""; ++ result = mName + '=' + mValue; ++ if (mExplicitPath) ++ result += L1("; $Path=\"") + mPath + L1("\""); + if (!mDomain.isEmpty()) +- result += "; $Domain=\""+ mDomain + "\""; ++ result += L1("; $Domain=\"") + mDomain + L1("\""); + } + return result; + } +@@ -157,8 +180,7 @@ + // Cookie domain match check + if (mDomain.isEmpty()) + { +- // No domain set, check hostname. +- if (fqdn != mHost) ++ if (fqdn != mHost) + return false; + } + else if (!domains.contains(mDomain)) +@@ -167,17 +189,30 @@ + return false; + + // Maybe the domain needs an extra dot. +- QString domain = "." + mDomain; ++ QString domain = '.' + mDomain; + if ( !domains.contains( domain ) ) + if ( fqdn != mDomain ) + return false; + } + + // Cookie path match check +- if( !path.isEmpty() && !path.startsWith(mPath) ) +- return false; // Path of URL does not start with cookie-path ++ if (mPath.isEmpty()) ++ return true; + +- return true; ++ // According to the netscape spec both http://www.acme.com/foobar, ++ // http://www.acme.com/foo.bar and http://www.acme.com/foo/bar ++ // match http://www.acme.com/foo. ++ // We only match http://www.acme.com/foo/bar ++ ++ if( path.startsWith(mPath) && ++ ( ++ (path.length() == mPath.length() ) || // Paths are exact match ++ (path[mPath.length()-1] == '/') || // mPath ended with a slash ++ (path[mPath.length()] == '/') // A slash follows. ++ )) ++ return true; // Path of URL starts with cookie-path ++ ++ return false; + } + + // KHttpCookieList +@@ -188,9 +223,9 @@ + int pathLen1 = ((KHttpCookie *)item1)->path().length(); + int pathLen2 = ((KHttpCookie *)item2)->path().length(); + if (pathLen1 > pathLen2) +- return 1; +- if (pathLen1 < pathLen2) + return -1; ++ if (pathLen1 < pathLen2) ++ return 1; + return 0; + } + +@@ -205,10 +240,18 @@ + // + KCookieJar::KCookieJar() + { +- cookieDomains.setAutoDelete( true ); +- globalAdvice = KCookieDunno; +- configChanged = false; +- cookiesChanged = false; ++ m_cookieDomains.setAutoDelete( true ); ++ 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); ++ } + } + + // +@@ -221,89 +264,184 @@ + // Not much to do here + } + ++static void removeDuplicateFromList(KHttpCookieList *list, KHttpCookie *cookiePtr, bool nameMatchOnly=false, bool updateWindowId=false) ++{ ++ QString domain1 = cookiePtr->domain(); ++ if (domain1.isEmpty()) ++ domain1 = cookiePtr->host(); ++ ++ for ( KHttpCookiePtr cookie=list->first(); cookie != 0; ) ++ { ++ QString domain2 = cookie->domain(); ++ if (domain2.isEmpty()) ++ domain2 = cookie->host(); ++ ++ if ( ++ (cookiePtr->name() == cookie->name()) && ++ ( ++ nameMatchOnly || ++ ( (domain1 == domain2) && (cookiePtr->path() == cookie->path()) ) ++ ) ++ ) ++ { ++ if (updateWindowId) ++ { ++ for(QValueList<long>::ConstIterator it = cookie->windowIds().begin(); ++ it != cookie->windowIds().end(); ++it) ++ { ++ long windowId = *it; ++ if (windowId && (cookiePtr->windowIds().find(windowId) == cookiePtr->windowIds().end())) ++ { ++ cookiePtr->windowIds().append(windowId); ++ } ++ } ++ } ++ KHttpCookiePtr old_cookie = cookie; ++ cookie = list->next(); ++ list->removeRef( old_cookie ); ++ break; ++ } ++ else ++ { ++ cookie = list->next(); ++ } ++ } ++} ++ ++ + // + // Looks for cookies in the cookie jar which are appropriate for _url. + // Returned is a string containing all appropriate cookies in a format + // which can be added to a HTTP-header without any additional processing. + // +-QString KCookieJar::findCookies(const QString &_url, bool useDOMFormat) ++QString KCookieJar::findCookies(const QString &_url, bool useDOMFormat, long windowId, KHttpCookieList *pendingCookies) + { + QString cookieStr; + QStringList domains; + QString fqdn; + QString path; + KHttpCookiePtr cookie; +- int protVersion = 1; +- int cookieCount = 0; ++ KCookieAdvice advice = m_globalAdvice; + + if (!parseURL(_url, fqdn, path)) +- { + return cookieStr; +- } ++ ++ bool secureRequest = (_url.find( L1("https://"), 0, false) == 0 || ++ _url.find( L1("webdavs://"), 0, false) == 0); + + extractDomains(fqdn, domains); +- bool secureRequest = (_url.find( "https://", 0, false) == 0); ++ ++ KHttpCookieList allCookies; ++ + for(QStringList::ConstIterator it = domains.begin(); +- it != domains.end(); ++ true; + ++it) + { +- KHttpCookieList *cookieList = cookieDomains[(*it)]; ++ KHttpCookieList *cookieList; ++ if (it == domains.end()) ++ { ++ cookieList = pendingCookies; // Add pending cookies ++ pendingCookies = 0; ++ if (!cookieList) ++ break; ++ } ++ else ++ { ++ QString key = (*it).isNull() ? L1("") : (*it); ++ cookieList = m_cookieDomains[key]; ++ if (!cookieList) ++ continue; // No cookies for this domain ++ } + +- if (!cookieList) +- continue; // No cookies for this domain ++ if (cookieList->getAdvice() != KCookieDunno) ++ advice = cookieList->getAdvice(); ++ ++ // Do not send cookies for this domain if policy is set to reject ++ // and we are not setup to automatically accept all cookies as ++ // session cookies... ++ if (advice == KCookieReject && ++ !(m_ignoreCookieExpirationDate && m_autoAcceptSessionCookies)) ++ { ++ if (it == domains.end()) ++ break; // Finished. ++ continue; ++ } + + for ( cookie=cookieList->first(); cookie != 0; cookie=cookieList->next() ) + { +- if (!cookie->match(fqdn, domains, path) && cookie->domain().isEmpty()) +- { +- // The following code is added because RFC 2109 is completely +- // ambigious when it comes what needs to be done when cookies +- // with empty "domain=" fields are present! The following code +- // makes such cookies available to all the domains/hosts under +- // the TLD of the cookie in question! +- QStringList cookieDomainList; +- extractDomains( cookie->host(), cookieDomainList ); +- +- int fqdnCount = domains.count(); +- int cookieDomainCount = cookieDomainList.count(); +- +- if ( domains[fqdnCount-2] != cookieDomainList[cookieDomainCount-2] && +- domains[fqdnCount-1] != cookieDomainList[cookieDomainCount-1] ) +- continue; +- } ++ if (!cookie->match(fqdn, domains, path)) ++ continue; + + if( cookie->isSecure() && !secureRequest ) + continue; + +- // Use first cookie to determine protocol version +- if (cookieCount == 0) ++ if( cookie->isHttpOnly() && useDOMFormat ) ++ continue; ++ ++ // Do not send expired cookies. ++ if ( cookie->isExpired (time(0)) ) + { +- protVersion = cookie->protocolVersion(); ++ // Note there is no need to actually delete the cookie here ++ // since the cookieserver will invoke ::saveCookieJar because ++ // of the state change below. This will then do the job of ++ // deleting the cookie for us. ++ m_cookiesChanged = true; ++ continue; + } +- if (useDOMFormat) ++ ++ if (windowId && (cookie->windowIds().find(windowId) == cookie->windowIds().end())) + { +- if (cookieCount > 0) +- cookieStr += "; "; +- cookieStr += cookie->cookieStr(true); ++ cookie->windowIds().append(windowId); + } +- else if (protVersion == 0) ++ ++ if (it == domains.end()) // Only needed when processing pending cookies ++ removeDuplicateFromList(&allCookies, cookie); ++ ++ allCookies.append(cookie); ++ } ++ if (it == domains.end()) ++ break; // Finished. ++ } ++ ++ ++ int cookieCount = 0; ++ ++ int protVersion=0; ++ for ( cookie=allCookies.first(); cookie != 0; cookie=allCookies.next() ) ++ { ++ if (cookie->protocolVersion() > protVersion) ++ protVersion = cookie->protocolVersion(); ++ } ++ ++ for ( cookie=allCookies.first(); cookie != 0; cookie=allCookies.next() ) ++ { ++ if (useDOMFormat) ++ { ++ if (cookieCount > 0) ++ cookieStr += L1("; "); ++ cookieStr += cookie->cookieStr(true); ++ } ++ else ++ { ++ if (cookieCount == 0) + { +- if (cookieCount == 0) +- cookieStr += "Cookie: "; +- else +- cookieStr += "; "; +- cookieStr += cookie->cookieStr(false); ++ cookieStr += L1("Cookie: "); ++ if (protVersion > 0) ++ { ++ QString version; ++ version.sprintf("$Version=%d; ", protVersion); // Without quotes ++ cookieStr += version; ++ } + } + else + { +- if (cookieCount > 0) +- cookieStr += "\r\n"; +- cookieStr += "Cookie: "; +- cookieStr += cookie->cookieStr(false); ++ cookieStr += L1("; "); + } +- cookieCount++; ++ cookieStr += cookie->cookieStr(false); + } ++ cookieCount++; + } ++ + return cookieStr; + } + +@@ -323,17 +461,17 @@ + bool keepQuotes=false) + { + const char *s = header; +- + // Parse 'my_name' part + for(; (*s != '='); s++) + { + if ((*s=='\0') || (*s==';') || (*s=='\n')) + { +- // End of Name +- Value = ""; +- Name = header; +- Name.truncate( s - header ); +- Name = Name.stripWhiteSpace(); ++ // No '=' sign -> use string as the value, name is empty ++ // (behavior found in Mozilla and IE) ++ Name = ""; ++ Value = QString::fromLatin1(header); ++ Value.truncate( s - header ); ++ Value = Value.stripWhiteSpace(); + return (s); + } + } +@@ -366,12 +504,12 @@ + if ((*s=='\0') || (*s=='\n')) + { + // End of Name +- Value = header; ++ Value = QString::fromLatin1(header); + Value.truncate(s - header); + return (s); + } + } +- Value = header; ++ Value = QString::fromLatin1(header); + Value.truncate( s - header ); + + // *s == '\"'; +@@ -390,7 +528,7 @@ + while ((*s != '\0') && (*s != ';') && (*s != '\n')) + s++; + // End of Name +- Value = header; ++ Value = QString::fromLatin1(header); + Value.truncate( s - header ); + Value = Value.stripWhiteSpace(); + } +@@ -398,14 +536,14 @@ + + } + +-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()) +@@ -420,10 +558,18 @@ + QString &_path) + { + KURL kurl(_url); +- if (kurl.isMalformed()) ++ if (!kurl.isValid()) + return false; + + _fqdn = kurl.host().lower(); ++ if (kurl.port()) ++ { ++ if (((kurl.protocol() == L1("http")) && (kurl.port() != 80)) || ++ ((kurl.protocol() == L1("https")) && (kurl.port() != 443))) ++ { ++ _fqdn = L1("%1:%2").arg(kurl.port()).arg(_fqdn); ++ } ++ } + + // Cookie spoofing protection. Since there is no way a path separator + // or escape encoded character is allowed in the hostname according +@@ -435,19 +581,44 @@ + + _path = kurl.path(); + if (_path.isEmpty()) +- _path = "/"; ++ _path = L1("/"); ++ ++ QRegExp exp(L1("[\\\\/]\\.\\.[\\\\/]")); ++ // Weird path, cookie stealing attempt? ++ if (_path.find(exp) != -1) { ++ return false; // Deny everything!! ++ } ++ + return true; + } + + void KCookieJar::extractDomains(const QString &_fqdn, + QStringList &_domains) + { +- // Use fqdn only if the fqdn consists of numbers. +- if ((_fqdn[0] >= '0') && (_fqdn[0] <= '9')) ++ // Return numeric IPv6 addresses as is... ++ if (_fqdn[0] == '[') + { + _domains.append( _fqdn ); + return; + } ++ // Return numeric IPv4 addresses as is... ++ if ((_fqdn[0] >= '0') && (_fqdn[0] <= '9')) ++ { ++ bool allNumeric = true; ++ for(int i = _fqdn.length(); i--;) ++ { ++ if (!strchr("0123456789:.", _fqdn[i].latin1())) ++ { ++ allNumeric = false; ++ break; ++ } ++ } ++ if (allNumeric) ++ { ++ _domains.append( _fqdn ); ++ return; ++ } ++ } + + QStringList partList = QStringList::split('.', _fqdn, false); + +@@ -458,29 +629,36 @@ + { + if (partList.count() == 1) + break; // We only have a TLD left. +- if (partList.count() == 2) ++ ++ 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) + // We assume this is a TLD if it ends with .xx.yy or .x.yy +- if ((partList[0].length() <= 2) && +- (partList[1].length() == 2)) ++ if (partList[0].length() <= 2) + break; // This is a TLD. ++ ++ // Catch some TLDs that we miss with the previous check ++ // e.g. com.au, org.uk, mil.co ++ QCString t = partList[0].lower().utf8(); ++ if ((t == "com") || (t == "net") || (t == "org") || (t == "gov") || (t == "edu") || (t == "mil") || (t == "int")) ++ break; + } +- QString domain = partList.join("."); +- _domains.append("." + domain); ++ ++ QString domain = partList.join(L1(".")); ++ _domains.append('.' + domain); + _domains.append(domain); + partList.remove(partList.begin()); // Remove part + } + +- // Only URLs that would get in here are of type +- // "host.foo" or "host.co.fo" so simply append +- // a '.' on top to make sure they are stored under +- // the proper cookie domain. +- if (_domains.isEmpty()) +- _domains.append( "." + _fqdn ); +- + // Always add the FQDN at the end of the list for + // hostname == cookie-domainname checks! ++ _domains.append( '.' + _fqdn ); + _domains.append( _fqdn ); + } + +@@ -492,55 +670,73 @@ + // cookie_headers should be a concatenation of all lines of a HTTP-header + // which start with "Set-Cookie". The lines should be separated by '\n's. + // +-KHttpCookiePtr KCookieJar::makeCookies(const QString &_url, ++KHttpCookieList KCookieJar::makeCookies(const QString &_url, + const QCString &cookie_headers, + long windowId) + { +- KHttpCookiePtr cookieChain = 0; ++ KHttpCookieList cookieList; ++ KHttpCookieList cookieList2; + KHttpCookiePtr lastCookie = 0; + const char *cookieStr = cookie_headers.data(); + QString Name; + QString Value; + QString fqdn; + QString path; ++ bool crossDomain = false; + + if (!parseURL(_url, fqdn, path)) + { + // Error parsing _url +- return 0; ++ return KHttpCookieList(); + } ++ QString defaultPath; ++ int i = path.findRev('/'); ++ if (i > 0) ++ defaultPath = path.left(i); + + // The hard stuff :) + for(;;) + { + // check for "Set-Cookie" +- if (strncasecmp(cookieStr, "Set-Cookie:", 11) == 0) ++ if (strncmp(cookieStr, "Cross-Domain\n", 13) == 0) ++ { ++ cookieStr += 13; ++ crossDomain = true; ++ } ++ else if (strncasecmp(cookieStr, "Set-Cookie:", 11) == 0) + { + cookieStr = parseNameValue(cookieStr+11, Name, Value, true); + +- if (Name.isEmpty()) +- continue; +- + // Host = FQDN + // Default domain = "" +- // Default path = "" +- KHttpCookie *cookie = new KHttpCookie(fqdn, "", "", Name, Value); +- cookie->mWindowId = windowId; ++ // Default path according to rfc2109 ++ ++ KHttpCookie *cookie = new KHttpCookie(fqdn, L1(""), defaultPath, Name, Value); ++ if (windowId) ++ cookie->mWindowIds.append(windowId); ++ cookie->mCrossDomain = crossDomain; + + // Insert cookie in chain +- if (lastCookie) +- lastCookie->nextCookie = cookie; +- else +- cookieChain = cookie; ++ cookieList.append(cookie); + lastCookie = cookie; + } +- else if (lastCookie && (strncasecmp(cookieStr, "Set-Cookie2:", 12) == 0)) ++ else if (strncasecmp(cookieStr, "Set-Cookie2:", 12) == 0) + { +- // What the fuck is this? +- // Does anyone invent his own headers these days? +- // Read the fucking RFC guys! This header is not there! +- cookieStr +=12; +- // Continue with lastCookie ++ // Attempt to follow rfc2965 ++ cookieStr = parseNameValue(cookieStr+12, Name, Value, true); ++ ++ // Host = FQDN ++ // Default domain = "" ++ // Default path according to rfc2965 ++ ++ KHttpCookie *cookie = new KHttpCookie(fqdn, L1(""), defaultPath, Name, Value); ++ if (windowId) ++ cookie->mWindowIds.append(windowId); ++ cookie->mCrossDomain = crossDomain; ++ ++ // Insert cookie in chain ++ cookieList2.append(cookie); ++ lastCookie = cookie; + } + else + { +@@ -564,13 +760,12 @@ + // Name-Value pair follows + cookieStr = parseNameValue(cookieStr, Name, Value); + +- Name = Name.lower(); +- +- if (Name == "domain") ++ QCString cName = Name.lower().latin1(); ++ if (cName == "domain") + { + lastCookie->mDomain = Value.lower(); + } +- else if (Name == "max-age") ++ else if (cName == "max-age") + { + int max_age = Value.toInt(); + if (max_age == 0) +@@ -578,23 +773,33 @@ + else + lastCookie->mExpireDate = time(0)+max_age; + } +- else if (Name == "expires") ++ else if (cName == "expires") + { + // Parse brain-dead netscape cookie-format + lastCookie->mExpireDate = KRFCDate::parseDate(Value); + } +- else if (Name == "path") ++ else if (cName == "path") + { +- lastCookie->mPath = Value; ++ if (Value.isEmpty()) ++ lastCookie->mPath = QString::null; // Catch "" <> QString::null ++ else ++ lastCookie->mPath = KURL::decode_string(Value); ++ lastCookie->mExplicitPath = true; + } +- else if (Name == "version") ++ else if (cName == "version") + { + lastCookie->mProtocolVersion = Value.toInt(); + } +- else if (Name == "secure") ++ else if ((cName == "secure") || ++ (cName.isEmpty() && Value.lower() == L1("secure"))) + { + lastCookie->mSecure = true; + } ++ else if ((cName == "httponly") || ++ (cName.isEmpty() && Value.lower() == L1("httponly"))) ++ { ++ lastCookie->mHttpOnly = true; ++ } + } + + if (*cookieStr == '\0') +@@ -604,7 +809,14 @@ + cookieStr++; + } + +- return cookieChain; ++ // RFC2965 cookies come last so that they override netscape cookies. ++ while( !cookieList2.isEmpty() && (lastCookie = cookieList2.take(0)) ) ++ { ++ removeDuplicateFromList(&cookieList, lastCookie, true); ++ cookieList.append(lastCookie); ++ } ++ ++ return cookieList; + } + + /** +@@ -613,12 +825,12 @@ + * pairs. Any whitespace before "name" or around '=' is discarded. + * If no cookies are found, 0 is returned. + */ +-KHttpCookiePtr KCookieJar::makeDOMCookies(const QString &_url, ++KHttpCookieList KCookieJar::makeDOMCookies(const QString &_url, + const QCString &cookie_domstring, + long windowId) + { + // A lot copied from above +- KHttpCookiePtr cookieChain = 0; ++ KHttpCookieList cookieList; + KHttpCookiePtr lastCookie = 0; + + const char *cookieStr = cookie_domstring.data(); +@@ -630,7 +842,7 @@ + if (!parseURL(_url, fqdn, path)) + { + // Error parsing _url +- return 0; ++ return KHttpCookieList(); + } + + // This time it's easy +@@ -638,35 +850,25 @@ + { + cookieStr = parseNameValue(cookieStr, Name, Value); + +- if (Name.isEmpty()) { +- if (*cookieStr != '\0') +- cookieStr++; // Skip ';' or '\n' +- +- continue; +- } +- + // Host = FQDN + // Default domain = "" + // Default path = "" + KHttpCookie *cookie = new KHttpCookie(fqdn, QString::null, QString::null, + Name, Value ); +- cookie->mWindowId = windowId; +- +- // Insert cookie in chain +- if (lastCookie) +- lastCookie->nextCookie = cookie; +- else +- cookieChain = cookie; ++ if (windowId) ++ cookie |
