@@ -203,21 +203,22 @@ jstring = A.word8 DOUBLE_QUOTE *> jstring_
203203-- | Parse a string without a leading quote.
204204jstring_ :: Parser Text
205205jstring_ = {-# SCC "jstring_" #-} do
206− s <- A.scan False $ \s c -> if s then Just False
207− else if c == DOUBLE_QUOTE
208− then Nothing
209− else Just (c == BACKSLASH)
210− _ <- A.word8 DOUBLE_QUOTE
211− s1 <- if BACKSLASH `B.elem` s
212− then case unescape s of
213− Right r -> return r
214− Left err -> fail err
215− else return s
216−
206+ (s, (_, escaped)) <- A.runScanner (False, False) go
207+ _ <- A.anyWord8
208+ s1 <- if escaped
209+ then case unescape s of
210+ Right r -> return r
211+ Left err -> fail err
212+ else return s
217213 case decodeUtf8' s1 of
218− Right r -> return r
219− Left err -> fail $ show err
220−
214+ Right r -> return r
215+ Left err -> fail $ show err
216+ where go (a, b) c
217+ | a = Just (False, b)
218+ | c == DOUBLE_QUOTE = Nothing
219+ | otherwise = let a' = c == backSlash
220+ in Just (a', a' || b)
221+ where backSlash = BACKSLASH
221222{-# INLINE jstring_ #-}
222223
223224unescape :: ByteString -> Either String ByteString