Skip to content

Commit 032f1a6

Browse files
author
Rick Owens
committed
Added "\r" to the valid line terminators. ...
"\r" still exists in many places in the wild, mainly because of Mac OS. For instance we recently hit a case where Gmail would export "\r" delimited CSV when exporting contacts.
1 parent 4f13734 commit 032f1a6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Data/Attoparsec/ByteString/Internal.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,10 @@ peekWord8' = T.Parser $ \t pos more lose succ ->
429429
-- | Match either a single newline character @\'\\n\'@, or a carriage
430430
-- return followed by a newline character @\"\\r\\n\"@.
431431
endOfLine :: Parser ()
432-
endOfLine = (word8 10 >> return ()) <|> (string "\r\n" >> return ())
432+
endOfLine =
433+
(string "\r\n" >> return ())
434+
<|> (word8 10 >> return ())
435+
<|> (word8 13 >> return ())
433436

434437
-- | Terminal failure continuation.
435438
failK :: Failure a

Data/Attoparsec/Text/Internal.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,10 @@ peekChar' = do
431431
-- | Match either a single newline character @\'\\n\'@, or a carriage
432432
-- return followed by a newline character @\"\\r\\n\"@.
433433
endOfLine :: Parser ()
434-
endOfLine = (char '\n' >> return ()) <|> (string "\r\n" >> return ())
434+
endOfLine =
435+
(string "\r\n" >> return ())
436+
<|> (char '\n' >> return ())
437+
<|> (char '\r' >> return ())
435438

436439
-- | Terminal failure continuation.
437440
failK :: Failure a

0 commit comments

Comments
 (0)