@@ -203,21 +203,22 @@ jstring = A.word8 DOUBLE_QUOTE *> jstring_
203-- | Parse a string without a leading quote.
203-- | Parse a string without a leading quote.
204jstring_ :: Parser Text
204jstring_ :: Parser Text
205jstring_ = {-# SCC "jstring_" #-} do
205jstring_ = {-# SCC "jstring_" #-} do
206− s <- A.scan False $ \s c -> if s then Just False
206+ (s, (_, escaped)) <- A.runScanner (False, False) go
207− else if c == DOUBLE_QUOTE
207+ _ <- A.anyWord8
208− then Nothing
208+ s1 <- if escaped
209− else Just (c == BACKSLASH)
210− _ <- A.word8 DOUBLE_QUOTE
211− s1 <- if BACKSLASH `B.elem` s
212− then case unescape s of
209+ then case unescape s of
213− Right r -> return r
210+ Right r -> return r
214− Left err -> fail err
211+ Left err -> fail err
215− else return s
212+ else return s
217 case decodeUtf8' s1 of
213 case decodeUtf8' s1 of
218− Right r -> return r
214+ Right r -> return r
219− Left err -> fail $ show err
215+ Left err -> fail $ show err
220−
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
221{-# INLINE jstring_ #-}
222{-# INLINE jstring_ #-}
223unescape :: ByteString -> Either String ByteString
224unescape :: ByteString -> Either String ByteString