Changed date-parsing routines to be less strict when parsing date
strings, i.e. to accept junk after a valid date specification. This is in order to support e.g. Netscape 2.x upto 4.7x, which illegally send an added length field in the If-Modified-Since header, i.e.: If-Modified-Since: Wed, 28 Mar 2001 05:40:23 GMT; length=5912 This unconforming behaviour is known since 1996, yet nothing ever changed. How sad.
This commit is contained in:
@ -371,16 +371,16 @@
|
||||
|
||||
(defun parse-rfc1123-date (string &optional (start 0) (end (length string)))
|
||||
(with-lws-trimmed-bounds (string start end)
|
||||
(unless (= 29 (- end start))
|
||||
(unless (<= 29 (- end start))
|
||||
(error 'clash-syntax-error :fragment (subseq string start end)
|
||||
:reason
|
||||
"Invalid length for rfc1123-date (too short or too long)"))
|
||||
"Invalid length for rfc1123-date (too short)"))
|
||||
(let ((day (parse-http-day string (+ start 5) (+ start 7)))
|
||||
(month (lookup-month-by-name string (+ start 8) (+ start 11)))
|
||||
(year (parse-http-year string (+ start 12) (+ start 16))))
|
||||
(multiple-value-bind (hour min sec)
|
||||
(parse-http-time string (+ start 17) (+ start 25))
|
||||
(unless (string= string " GMT" :start1 (+ start 25) :end1 end)
|
||||
(unless (string= string " GMT" :start1 (+ start 25) :end1 (+ start 29))
|
||||
(error 'clash-syntax-error :fragment (subseq string start end)
|
||||
:reason
|
||||
"Invalid time-zone (must be GMT)"))
|
||||
@ -397,7 +397,7 @@
|
||||
(defun parse-rfc850-date (string &optional (start 0) (end (length string)))
|
||||
(with-lws-trimmed-bounds (string start end)
|
||||
(let ((day-end (position #\, string :start start :end end)))
|
||||
(unless (and day-end (= 24 (- end day-end))
|
||||
(unless (and day-end (<= 24 (- end day-end))
|
||||
(<= 6 (- day-end start) 9))
|
||||
(error 'clash-syntax-error :fragment (subseq string start end)
|
||||
:reason
|
||||
@ -407,7 +407,8 @@
|
||||
(year (parse-http-year string (+ day-end 9) (+ day-end 11))))
|
||||
(multiple-value-bind (hour min sec)
|
||||
(parse-http-time string (+ day-end 12) (+ day-end 20))
|
||||
(unless (string= string " GMT" :start1 (+ day-end 20) :end1 end)
|
||||
(unless (string= string " GMT" :start1 (+ day-end 20)
|
||||
:end1 (+ day-end 24))
|
||||
(error 'clash-syntax-error :fragment (subseq string start end)
|
||||
:reason
|
||||
"Invalid time-zone (must be GMT)"))
|
||||
@ -423,10 +424,10 @@
|
||||
|
||||
(defun parse-asctime-date (string &optional (start 0) (end (length string)))
|
||||
(with-lws-trimmed-bounds (string start end)
|
||||
(unless (= 24 (- end start))
|
||||
(unless (<= 24 (- end start))
|
||||
(error 'clash-syntax-error :fragment (subseq string start end)
|
||||
:reason
|
||||
"Invalid length for asctime-date (too short or too long)"))
|
||||
"Invalid length for asctime-date (too short)"))
|
||||
(let ((day (parse-http-day string (+ start 8) (+ start 10)))
|
||||
(month (lookup-month-by-name string (+ start 4) (+ start 7)))
|
||||
(year (parse-http-year string (+ start 20) (+ start 24))))
|
||||
|
||||
Reference in New Issue
Block a user