diff --git a/collects/net/head-unit.ss b/collects/net/head-unit.ss index b9b9404..efecd46 100644 --- a/collects/net/head-unit.ss +++ b/collects/net/head-unit.ss @@ -17,6 +17,9 @@ (define re:continue (regexp "^[ \t\v]")) (define (validate-header s) + (let ([m (regexp-match #rx"[^\0-\277]" s)]) + (when m + (error 'validate-header "non-Latin-1 character in string: ~a" (car m)))) (let ([len (string-length s)]) (let loop ([offset 0]) (cond diff --git a/collects/net/mime-unit.ss b/collects/net/mime-unit.ss index d1de387..31673c9 100644 --- a/collects/net/mime-unit.ss +++ b/collects/net/mime-unit.ss @@ -214,8 +214,8 @@ (define mime-analyze (opt-lambda (input (part #f)) - (let* ((iport (if (string? input) - (open-input-string input) + (let* ((iport (if (bytes? input) + (open-input-bytes input) input)) (headers (get-headers iport)) (msg (if part diff --git a/collects/net/smtp-unit.ss b/collects/net/smtp-unit.ss index a3d7e1f..5414c19 100644 --- a/collects/net/smtp-unit.ss +++ b/collects/net/smtp-unit.ss @@ -40,7 +40,12 @@ (define (protect-line l) ;; If begins with a dot, add one more - (if (or (string=? "" l) (not (char=? #\. (string-ref l 0)))) + (if (or (equal? l #"") + (equal? l "") + (and (string? l) + (not (char=? #\. (string-ref l 0)))) + (and (bytes? l) + (not (= (char->integer #\.) (bytes-ref l 0))))) l (string-append "." l)))