From: Simon Marlow Date: Thu, 2 Jul 2009 08:14:15 +0000 (+0000) Subject: a byte between 0x80 and 0xBF is illegal immediately (#3341) X-Git-Tag: ghc-darcs-git-switchover~376 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=97080d8293694fbf4e51556352e3fd196a43bdde;p=ghc-base.git a byte between 0x80 and 0xBF is illegal immediately (#3341) --- diff --git a/GHC/IO/Encoding/UTF8.hs b/GHC/IO/Encoding/UTF8.hs index 0efb187..99928e0 100644 --- a/GHC/IO/Encoding/UTF8.hs +++ b/GHC/IO/Encoding/UTF8.hs @@ -83,7 +83,7 @@ utf8_decode if not (validate3 c0 c1 c2) then invalid else do writeCharBuf oraw ow (chr3 c0 c1 c2) loop (ir+3) (ow+1) - | otherwise -> + | c0 >= 0xf0 -> if iw - ir < 4 then done ir ow else do c1 <- readWord8Buf iraw (ir+1) c2 <- readWord8Buf iraw (ir+2) @@ -91,6 +91,8 @@ utf8_decode if not (validate4 c0 c1 c2 c3) then invalid else do writeCharBuf oraw ow (chr4 c0 c1 c2 c3) loop (ir+4) (ow+1) + | otherwise -> + invalid where invalid = if ir > ir0 then done ir ow else ioe_decodingError