diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2017-11-16 12:33:00 +0100 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2017-11-16 12:33:00 +0100 |
commit | 81ea2465877ad2cafdb61054ae29a725787acd2d (patch) | |
tree | 599846a886aadfb5eca7544c19c3a74e2f3ff2fd | |
parent | b5283f8fd7c52a0da0f423d743fa299488a917d7 (diff) |
debbugs: Fix RFC822 date parser.
* debbugs/rfc822.scm (rfc822-parse-date): Check if string matches
before using "match:count".
-rw-r--r-- | debbugs/rfc822.scm | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/debbugs/rfc822.scm b/debbugs/rfc822.scm index 7d9fe3f..d4bb0f3 100644 --- a/debbugs/rfc822.scm +++ b/debbugs/rfc822.scm @@ -295,21 +295,22 @@ using the optional tokenizer table OPTS." (else #f))) (let* ((pattern "((Sun|Mon|Tue|Wed|Thu|Fri|Sat)[[:space:]]*,)?[[:space:]]*([[:digit:]]+)[[:space:]]*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[[:space:]]*([[:digit:]][[:digit:]]([[:digit:]][[:digit:]])?)[[:space:]]+([[:digit:]][[:digit:]])[[:space:]]*:[[:space:]]*([[:digit:]][[:digit:]])([[:space:]]*:[[:space:]]*([[:digit:]][[:digit:]]))?([[:space:]]+([+-][[:digit:]][[:digit:]][[:digit:]][[:digit:]]|[A-Z][A-Z][A-Z]?))?") - (m (string-match pattern string)) - (matches (map (lambda (n) - (match:substring m n)) - (iota (match:count m) 0)))) - (match matches - ((_ _ dow dom mon yr _ hour min _ sec _ tz) - (values (year->number yr) - (mon->number mon) - (string->number dom) - (string->number hour) - (string->number min) - (and sec (string->number sec)) - (and tz (tz->number tz)) - (and dow (dow->number dow)))) - (_ (values #f #f #f #f #f #f #f #f))))) + (m (string-match pattern string))) + (if m + (match (map (lambda (n) + (match:substring m n)) + (iota (match:count m) 0)) + ((_ _ dow dom mon yr _ hour min _ sec _ tz) + (values (year->number yr) + (mon->number mon) + (string->number dom) + (string->number hour) + (string->number min) + (and sec (string->number sec)) + (and tz (tz->number tz)) + (and dow (dow->number dow)))) + (_ (values #f #f #f #f #f #f #f #f))) + (values #f #f #f #f #f #f #f #f)))) (define (rfc822-date->date string) (receive (year month day hour min sec tz . rest) |