fix a problem in WXME decoding

Thanks to Robby for the test case and for narrowing down the problem.
This commit is contained in:
Matthew Flatt 2016-06-06 09:20:47 -06:00
parent 7c857706d7
commit e01e970722
2 changed files with 21 additions and 0 deletions

View File

@ -381,6 +381,15 @@
(unless recur? (inc-item-count))
(let ([s (with-handlers ([exn:fail:read? (lambda (x) #f)])
(read si))])
(when (and recur? s)
;; It's ok to have extra whitespace when reading a byte
;; string in a sequence
(let loop ()
(define c (peek-byte si))
(unless (eof-object? c)
(when (char-whitespace? (integer->char c))
(read-byte si)
(loop)))))
(if (or (not s)
(not (eof-object? (read-byte si))))
(fail)

View File

@ -927,6 +927,18 @@
#"")
(expect (send fi2 ok?) #f)
(let ()
(define (wash-it b)
(define out-base (new editor-stream-out-bytes-base%))
(define out-stream (make-object editor-stream-out% out-base))
(send out-stream put (bytes-length b) b)
(define bstr (send out-base get-bytes))
(define in-base (make-object editor-stream-in-bytes-base% bstr))
(define in-stream (make-object editor-stream-in% in-base))
(send in-stream get-unterminated-bytes))
(define ex-b #"object ... ;;\351\232\234\347\242\215\347\211\251\345\210\227\350\241\250")
(expect (wash-it ex-b) ex-b))
;; ----------------------------------------
;; Save & load