Changeset 11881 in project


Ignore:
Timestamp:
09/03/08 20:18:35 (13 years ago)
Author:
sjamaan
Message:

Implement hack so escaped newlines are accepted

Location:
release/4/intarweb/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/intarweb/trunk/intarweb.scm

    r11832 r11881  
    270270                  (parse-header-line prev-line headers))
    271271              (if (char-whitespace? (string-ref line 0)) ; Continuation char?
    272                   (loop (string-append prev-line line) (read-line port)
     272                  (loop (string-append prev-line line)
     273                        (read-line port)
    273274                        headers)
    274                   (loop line (read-line port)
    275                         (parse-header-line prev-line headers))))))))
     275                  (if (string=? (string-take-right prev-line 1) "\\") ; escaped?
     276                      ;; XXX Test if this works with all combinations of \r\n
     277                      ;; with prepended backslashes. We don't care about
     278                      ;; malformed stuff like "foo\\\\\n" or \ with missing "
     279                      (loop (string-append prev-line "\n" line)
     280                            (read-line port)
     281                            headers)
     282                      (loop line (read-line port)
     283                            (parse-header-line prev-line headers)))))))))
    276284
    277285(define (signal-http-condition msg type . more-info)
  • release/4/intarweb/trunk/tests/run.scm

    r11855 r11881  
    1 (require-extension test extras regex srfi-1 uri-generic intarweb)
     1(require-extension test extras regex uri-generic intarweb)
    22
    33(define-syntax test-error*
     
    6565           '("foo, bar" "blah") (header-values 'unknown headers))))
    6666  (test-group "Miscellaneous"
    67     (test-error "Missing header contents" (test-read-headers "foo\r\n\r\n"))
    68     ;; RFC 2616 2.2
    69     ;; "The backslash character ("\") MAY be used as a single-character
    70     ;; quoting mechanism only within quoted-string and comment constructs."
    71     ;;     quoted-pair = "\" CHAR
    72     ;; CHAR implies any char, *including* CR/LF. This is clarified by RFC 822,
    73     ;; on which RFC 2616 is based.
    74     ;; Apparently, even \CRLF is allowed (as opposed to \CR\LF)
    75     (test "Embedded newlines"
    76           "bar\r\nqux"
    77           ;; XXX Should we interpret "\\\r\n" as "\r\n", too?
    78           (test-read-headers "Foo: \"bar\\\r\\\nqux\""))))
     67    (parameterize ((header-parsers `((foo . ,(multiple identity)))))
     68      (test-error "Missing header contents" (test-read-headers "foo\r\n\r\n"))
     69      ;; RFC 2616 2.2
     70      ;; "The backslash character ("\") MAY be used as a single-character
     71      ;; quoting mechanism only within quoted-string and comment constructs."
     72      ;;     quoted-pair = "\" CHAR
     73      ;; CHAR implies any char, *including* CR/LF. This is clarified by RFC 822,
     74      ;; on which RFC 2616 is based.
     75      ;; Apparently, even \CRLF is allowed (as opposed to \CR\LF)
     76      (test "Embedded newlines"
     77            '("bar\r\nqux")
     78            ;; XXX Should we interpret "\\\r\n" as "\r\n", too?
     79            (header-values 'foo (test-read-headers "Foo: \"bar\\\r\\\nqux\""))))))
    7980
    8081(test-group "Specialized header parsers"
Note: See TracChangeset for help on using the changeset viewer.