storage/curl: make timestamp parsing more robust

According to the latest WebDAV specification (RFC4918),
timestamp string in the getlastmodified property is formatted
as rfc1123-date, such as "Sun, 06 Nov 1994 08:49:37 GMT".
However, to process responses from servers in the older style
format specified in RFC2518, timestamps in the HTTP-date format
had better be accepted.

As described in the libcurl api documentation, curl_getdate() can handle
timestamp strings in HTTP-date formats, including rfc1123-date.

https://www.rfc-editor.org/rfc/rfc4918#section-15.7
https://www.rfc-editor.org/rfc/rfc2518.html#section-13.7
https://curl.se/libcurl/c/curl_getdate.html
This commit is contained in:
BurroCargado 2022-09-29 19:48:27 +09:00 committed by Max Kellermann
parent df71b07e9d
commit 99e65c58ce

View File

@ -194,12 +194,7 @@ ParseStatus(const char *s, size_t length) noexcept
static std::chrono::system_clock::time_point
ParseTimeStamp(const char *s) noexcept
{
try {
// TODO: make this more robust
return ParseTimePoint(s, "%a, %d %b %Y %T");
} catch (...) {
return std::chrono::system_clock::time_point::min();
}
return std::chrono::system_clock::from_time_t(curl_getdate(s, nullptr));
}
[[gnu::pure]]