Commit 99e65c58 authored by BurroCargado's avatar BurroCargado Committed by Max Kellermann

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
parent df71b07e
......@@ -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]]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment