Web lists-archives.com

strange behavior of KCookieServer




Hello to everyone,
in my ongoing attempt to integrate Konqueror and QWebEngine, I'm still 
struggling with a way to share cookies between QWebEngineCookieStore and 
KCookieServer. While investigating this issue, I found a problem when adding 
cookies to KCookieServer by hand which doesn't seem happen when using 
Konqueror with either KHTML or KWebKitPart. I think I know how I could solve 
(or work around) this issue but I don't understand why it's happening and I'd 
like some insight about this.

The isssue I noticed concerns cookies with an "expire" field and I believe, 
after looking at the code for KCookieJar and KCookieServer, it is related to 
time zone handling by KCookieJar.

I live in Italy, so my time zone is CEST, which (unless I'm mistaken) means 
GTM+2. If now (16:30 CEST, 14:30 GMT), a web page sent me a cookie which 
should expire in 30 minutes (17:00 CEST, 15:00 GMT), it would have an 
"expires" field like "expires: Fri, 13-Jul-2018 15:00:00 GMT".

I tried to add such a cookie from the command line, like this:

qdbus org.kde.kcookiejar5 /modules/kcookiejar addCookies http://xyz.it "Set-
Cookie: test=hello; expires=Fri, 13-Jul-2018 15:00:00 GMT; domain=.xyz.it; 
path=/" 0

but in the cookies page in System Settings doesn't show the cookie. If I 
change the "expires" field in the cookie so that the hour becomes 17:00:00, the 
cookie is added.

The problem, I believe, is that KCookieJar::parseDate calls 
QLocale::toDateTime, which seems to create a QDateTime with the local time 
zone (in my case, CEST). This means that the cookie expire date, which was in 
GMT, is interpreted as if it were in CEST and, of course, the cookie is 
considered expired.

Thanks in advance for any help in understanding what's happening.

Stefano