BHttpTime: cookie strings are in english, so strptime now uses POSIX (english) locale to parse them
Change-Id: I863b59a3f3c27b656325752af7939576becf32f1 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5629 Tested-by: Commit checker robot <[email protected]> Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
124ae7cc2f
commit
e89a5cc418
@@ -12,6 +12,7 @@
|
||||
#include <new>
|
||||
|
||||
#include <cstdio>
|
||||
#include <locale.h>
|
||||
|
||||
|
||||
// The formats used should be, in order of preference (according to RFC2616,
|
||||
@@ -47,6 +48,8 @@ static const char* kDateFormats[] = {
|
||||
"%a %d %b %H:%M:%S %Y"
|
||||
};
|
||||
|
||||
static locale_t posix = newlocale(LC_ALL_MASK, "POSIX", (locale_t)0);
|
||||
|
||||
#ifdef LIBNETAPI_DEPRECATED
|
||||
using namespace BPrivate;
|
||||
#else
|
||||
@@ -109,6 +112,10 @@ BHttpTime::Parse()
|
||||
|
||||
memset(&expireTime, 0, sizeof(struct tm));
|
||||
|
||||
// Save the current locale, switch to POSIX for strptime to match strings
|
||||
// in English, switch back when we're done.
|
||||
locale_t current = uselocale(posix);
|
||||
|
||||
fDateFormat = B_HTTP_TIME_FORMAT_PARSED;
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof(kDateFormats) / sizeof(const char*);
|
||||
@@ -125,6 +132,8 @@ BHttpTime::Parse()
|
||||
}
|
||||
}
|
||||
|
||||
uselocale(current);
|
||||
|
||||
// Did we identify some valid format?
|
||||
if (fDateFormat == B_HTTP_TIME_FORMAT_PARSED)
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user