Summary: | Konqueror treats persistent cookies from amazon.com as session cookies [regression in 4] | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | John Miller <neuromancerx1> |
Component: | kcookiejar | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED WORKSFORME | ||
Severity: | normal | CC: | kde-bugs, lemma, zahl |
Priority: | NOR | Keywords: | triaged |
Version: | 3.5 | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | fix time parsing |
Description
John Miller
2007-05-09 21:33:58 UTC
SVN commit 709516 by adawit: Fix for BR# 145244. Persistent cookies are treated like session cookies. BUG: 145244 M +36 -0 kcookiejar.cpp --- branches/KDE/3.5/kdelibs/kioslave/http/kcookiejar/kcookiejar.cpp #709515:709516 @@ -670,6 +670,37 @@ _domains.prepend( _fqdn ); } + +/* + Changes dates in from the following format + + Wed Sep 12 07:00:00 2007 GMT + to + Wed Sep 12 2007 07:00:00 GMT + + to allow KRFCDate::parseDate to properly parse expiration date formats + used in cookies by some servers such as amazon.com. See BR# 145244. +*/ +static QString fixupDateTime(const QString& dt) +{ + const int index = dt.find(QRegExp("[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}")); + + if (index > -1) + { + QStringList dateStrList = QStringList::split(' ', dt.mid(index)); + if (dateStrList.count() > 1) + { + QString date = dateStrList[0]; + dateStrList[0] = dateStrList[1]; + dateStrList[1] = date; + date = dt; + return date.replace(index, date.length(), dateStrList.join(" ")); + } + } + + return dt; +} + // // This function parses cookie_headers and returns a linked list of // KHttpCookie objects for all cookies found in cookie_headers. @@ -795,6 +826,11 @@ { // Parse brain-dead netscape cookie-format lastCookie->mExpireDate = KRFCDate::parseDate(Value); + + // Workaround for servers that send the expiration date in + // 'Wed Sep 12 07:00:00 2007 GMT' format. See BR# 145244. + if (lastCookie->mExpireDate == 0) + lastCookie->mExpireDate = KRFCDate::parseDate(fixupDateTime(Value)); } else if (cName == "path") { This bug has returned in trunk. I'm currently using svn revision 866463 I can't confirm this on trunk r870274. Can you please try reproducing it? I probably should have clarified that this bug is now in kde 4 konqueror. It's still present for me in revision 870578. I usually update from svn once a week, and it wasn't present in whichever revision I was using before 866463. Created attachment 36405 [details]
fix time parsing
As I'm affected by this bug I did create a patch to fix it. I'm not very familiar with KDE and Qt coding so I don't know if this is the right place to fix this issue or if it might cause other problems.
So please tell me if there are any problems with my patch. If not I'd like to see this fixed in svn.
SVN commit 1063612 by adawit: - Fixed parsing of cookie expiration dates. This resolves the problem of non-session cookies being treated as session ones. - Fixed problems with the recent Y2K38 fix. CCBUG: 145244 CCBUG: 176731 CCBUG: 187792 CCBUG: 191318 M +36 -40 kcookiejar.cpp M +5 -1 kcookiejar.h M +9 -4 tests/cookie.test WebSVN link: http://websvn.kde.org/?view=rev&revision=1063612 Looks fine these days.. |