Properly parse dates in cookies when running in non-English locale
ClosedPublic

Authored by schwab on Nov 24 2017, 10:35 AM.

Details

Summary

Use the C locale when parsing dates in cookies, since only English week
and month names are allowed

BUG: 387254

Diff Detail

Repository
R241 KIO
Lint
Lint Skipped
Unit
Unit Tests Skipped
schwab created this revision.Nov 24 2017, 10:35 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptNov 24 2017, 10:35 AM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
anthonyfieroni added inline comments.
src/ioslaves/http/kcookiejar/kcookiejar.cpp
78–84

You can use not predefined days name

QLocale locale = QLocale::c();
for (int i = 1; i < 8; ++i) {
    if (weekday.startsWith(locale.dayName(i, QLocale::ShortFormat), Qt::CaseInsensitive)) {
schwab updated this revision to Diff 22970.Nov 26 2017, 5:06 PM

Use the week names from the C locale

schwab marked an inline comment as done.Nov 26 2017, 5:08 PM

Thanks for the fix, looks good, just two minor improvement suggestions.

src/ioslaves/http/kcookiejar/kcookiejar.cpp
78 ↗(On Diff #22970)

"i" and "l" local variables are hard to read, please rename to locale or cLocale

119 ↗(On Diff #22970)

You could (and probably should) do like the above loop and move QLocale::c() to a local variable defined before the for loop.
QLocale::c() creates a QLocale instance every time, so better do that only once.

schwab updated this revision to Diff 22971.Nov 26 2017, 6:07 PM

Rename variable and constify.

schwab marked 2 inline comments as done.Nov 26 2017, 6:08 PM
dfaure accepted this revision.Nov 26 2017, 7:08 PM
dfaure added inline comments.
src/ioslaves/http/kcookiejar/kcookiejar.cpp
117

indentation seems strange, but maybe that's just phabricator messing up...

This revision is now accepted and ready to land.Nov 26 2017, 7:08 PM
aacid closed this revision.Jan 5 2018, 10:02 PM