Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
Parser.takeMultiLine: parse line with actualLine instead of takeLine
Browse files Browse the repository at this point in the history
takeLine accepts empty strings which causes an infinite loop
in takeMultiLine when the opening ":{" is not properly closed.
  • Loading branch information
thielema committed Jan 5, 2024
1 parent e478293 commit 05df588
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion haddock-library/src/Documentation/Haddock/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,15 @@ takeLine = try (takeWhile (/= '\n') <* endOfLine)
endOfLine :: Parser ()
endOfLine = void "\n" <|> Parsec.eof


actualLine :: Parser Text
actualLine = takeWhile (/= '\n') <* void "\n"

takeMultiLine :: Parser Text
takeMultiLine =
T.unlines <$>
(try ":{" *> Parsec.manyTill takeLine (try $ skipHorizontalSpace *> ":}\n"))
(try ":{" *>
Parsec.manyTill actualLine (try $ skipHorizontalSpace *> ":}\n"))

takeLineOrMultiLine :: Parser Text
takeLineOrMultiLine =
Expand Down

0 comments on commit 05df588

Please sign in to comment.