From: Matt Birkholz Date: Sat, 24 Nov 2018 22:47:36 +0000 (-0700) Subject: runtime/rfc2822-headers: Check for the eof-object. X-Git-Tag: mit-scheme-pucked-10.1.2~13 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=3cfdbe75b454affa9175d72c4b8d7b24b3e2b712;p=mit-scheme.git runtime/rfc2822-headers: Check for the eof-object. --- diff --git a/src/runtime/rfc2822-headers.scm b/src/runtime/rfc2822-headers.scm index cf4807937..ed181e8c7 100644 --- a/src/runtime/rfc2822-headers.scm +++ b/src/runtime/rfc2822-headers.scm @@ -191,14 +191,18 @@ USA. byte (builder))) ((fix:= 13 byte) - (if (fix:= 10 (peek-u8 port)) - (read-u8 port) - (parse-error port "Invalid line ending:" - 'read-ascii-line)) + (let ((byte (peek-u8 port))) + (cond ((eof-object? byte) + (parse-error port "Invalid line ending:" + 'read-ascii-line)) + ((fix:= 10 byte) + (read-u8 port)) + (else + (parse-error port "Invalid line ending:" + 'read-ascii-line)))) (builder)) ((fix:= 10 byte) - (parse-error port "Invalid line ending:" 'read-ascii-line) - (builder)) + (parse-error port "Invalid line ending:" 'read-ascii-line)) ((and (fix:<= 32 byte) (fix:<= byte 126)) (builder (integer->char byte)) (loop)) @@ -208,9 +212,11 @@ USA. (define (peek-ascii-char port) (let ((byte (peek-u8 port))) - (if (eof-object? byte) - byte - (integer->char byte)))) + (cond ((eof-object? byte) + byte) + ((and (fix:<= 32 byte) (fix:<= byte 126)) + (integer->char byte)) + (else (parse-error port "Illegal character:" 'peek-ascii-char))))) (define (skip-wsp-left string start end) (let loop ((i start))