From 99e65c58ced5c54f8ba8ac5e0d5df52fbd8750b4 Mon Sep 17 00:00:00 2001 From: BurroCargado Date: Thu, 29 Sep 2022 19:48:27 +0900 Subject: [PATCH] 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 --- src/storage/plugins/CurlStorage.cxx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx index 1cf83639b..8c34badb2 100644 --- a/src/storage/plugins/CurlStorage.cxx +++ b/src/storage/plugins/CurlStorage.cxx @@ -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]]