adds error message to dav, when an invalid date format is specified for the -u option

Mon, 09 Oct 2017 14:55:47 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 09 Oct 2017 14:55:47 +0200
changeset 329
2dc61cc5a8ac
parent 328
18a8c7895b6d
child 330
54819e984a19

adds error message to dav, when an invalid date format is specified for the -u option

dav/main.c file | annotate | diff | comparison | revisions
libidav/utils.c file | annotate | diff | comparison | revisions
--- a/dav/main.c	Sat Oct 07 10:40:21 2017 +0200
+++ b/dav/main.c	Mon Oct 09 14:55:47 2017 +0200
@@ -648,6 +648,13 @@
     time_t t = -1;
     if(update) {
         t = util_parse_lastmodified(update);
+        if (t == 0) {
+            fprintf(stderr,
+                    "Invalid date format. Possible formats are:\n"
+                    "  RFC-1123 - example: Thu, 29 Nov 2012 21:35:35 GMT\n"
+                    "  RFC-3339 - example: 2012-11-29T21:35:35Z\n");
+            return -1;
+        }
     }
     
     int recursive = cmd_getoption(a, "recursive") ? 1 : 0;
--- a/libidav/utils.c	Sat Oct 07 10:40:21 2017 +0200
+++ b/libidav/utils.c	Mon Oct 09 14:55:47 2017 +0200
@@ -181,8 +181,9 @@
     } else {
         time_t result = curl_getdate(str, NULL);
         if(result == -1) {
-            // some shit server don't comply with the WebDAV standard and
-            // use ISO-8601 dates for lastmodified (e.g. Microsoft Sharepoint)
+            // fall back to the ISO-8601 format (e.g. Microsoft Sharepoint
+            // illegally uses this format for lastmodified, but also some
+            // users might want to give an ISO-8601 date)
             return util_parse_creationdate(str);
         } else {
             return result;

mercurial