uu: protect from invalid input.

db4
John Benediktsson 2013-12-10 18:08:55 -08:00
parent c68db22281
commit 71ad43c0ab
1 changed files with 5 additions and 3 deletions

View File

@ -85,9 +85,11 @@ PRIVATE>
[ [ uu-encode ] with-string-writer ] with-string-reader ;
: uu-decode ( -- )
[ "begin" head? ] [ readln ] do until
[ dup "end" head? [ drop t ] [ ascii>binary write f ] if ]
[ readln ] do until ;
[ [ "begin" head? ] [ not ] bi or ] [ readln ] do until
[
dup [ "end" head? ] [ not ] bi or
[ drop t ] [ ascii>binary write f ] if
] [ readln ] do until ;
: uu>string ( seq -- seq )
[ [ uu-decode ] with-string-writer ] with-string-reader ;