disallow numeric escape sequences for characters outside Unicode range
authorMichael Ficarra <git@michael.ficarra.me>
Fri, 13 Nov 2015 04:46:48 +0000 (20:46 -0800)
committerMichael Ficarra <git@michael.ficarra.me>
Fri, 13 Nov 2015 04:46:48 +0000 (20:46 -0800)
Text/Parsec/Token.hs

index 27c1303..977d79f 100644 (file)
@@ -454,7 +454,9 @@ makeTokenParser languageDef
     charNum         = do{ code <- decimal
                                   <|> do{ char 'o'; number 8 octDigit }
                                   <|> do{ char 'x'; number 16 hexDigit }
-                        ; return (toEnum (fromInteger code))
+                        ; if code > 0x10FFFF
+                          then fail "invalid escape sequence"
+                          else return (toEnum (fromInteger code))
                         }
 
     charEsc         = choice (map parseEsc escMap)