On Sat, Jul 2, 2016 at 4:39 PM, William A Rowe Jr <wr...@rowe-clan.net> wrote:
> Relevant data points...
>
> https://tools.ietf.org/html/rfc7231#section-7.1.1.1
>
> There is no other supported time zone except GMT representing GMT.  That is
> the only value we may send.
>
> "Recipients of timestamp values are encouraged to be robust in parsing
> timestamps unless otherwise restricted by the field definition. For example,
> messages are occasionally forwarded over HTTP from a non-HTTP source that
> might generate any of the date and time specifications defined by the
> Internet Message Format. "
>
> We may accept an unusual timezone but should reformat as GMT in the
> response.

Great, that avoids double-parsing the date (but for TRACE1), so the
patch (attached) is no more introducing more cycles.

Regards,
Yann.
Index: server/util_script.c
===================================================================
--- server/util_script.c	(revision 1750971)
+++ server/util_script.c	(working copy)
@@ -665,28 +665,25 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex(
          * pass it on blindly because of restrictions on future or invalid values.
          */
         else if (!ap_cstr_casecmp(w, "Last-Modified")) {
-            apr_time_t last_modified_date = apr_date_parse_http(l);
-            if (last_modified_date != APR_DATE_BAD) {
+            apr_time_t parsed_date = apr_date_parse_rfc(l);
+            if (parsed_date != APR_DATE_BAD) {
+                apr_time_t last_modified_date = parsed_date;
+                apr_time_t now = apr_time_now();
+                if (parsed_date > now) {
+                    last_modified_date = now;
+                }
                 ap_update_mtime(r, last_modified_date);
                 ap_set_last_modified(r);
-                if (APLOGrtrace1(r)) {
-                    const char* datestr = apr_table_get(r->headers_out,
-                                                        "Last-Modified");
-                    apr_time_t timestamp = apr_date_parse_http(datestr);
-                    if (timestamp < last_modified_date) {
-                        char *last_modified_datestr = apr_palloc(r->pool,
-                                                                 APR_RFC822_DATE_LEN);
-                        apr_rfc822_date(last_modified_datestr, last_modified_date);
-                        ap_log_rerror(SCRIPT_LOG_MARK, APLOG_TRACE1, 0, r,
-                                      "The Last-Modified header value '%s' "
-                                      "(parsed as RFC822/RFC1123 datetime, "
-                                      "that assumes the GMT timezone) "
-                                      "has been replaced with: '%s'. "
-                                      "An origin server with a clock must not send "
-                                      "a Last-Modified date that is later than the "
-                                      "server's time of message origination.",
-                                      last_modified_datestr, datestr);
-                    }
+                if (APLOGrtrace1(r) &&
+                        (parsed_date > now ||
+                         parsed_date != apr_date_parse_http(l))) {
+                    ap_log_rerror(SCRIPT_LOG_MARK, APLOG_TRACE1, 0, r,
+                                  "The Last-Modified header value '%s' (%s) "
+                                  "has been replaced with '%s'", l,
+                                  parsed_date > now ? "in the future"
+                                                    : "non GMT",
+                                  apr_table_get(r->headers_out,
+                                                "Last-Modified"));
                 }
             }
             else {

Reply via email to