fix obviously wrong attoparsec parser

takeByteString can only be used at the end of a parser, not before other
input. This was a dumb enough mistake that I audited the rest of the
code base for similar mistakes. Pity that attoparsec cannot avoid it at
the type level.

Fixes git-annex forget propagation between repositories. (reversion
introduced in version 7.20190122)

Sponsored-by: Brock Spratlen on Patreon
This commit is contained in:
Joey Hess 2022-02-07 14:09:43 -04:00
parent 65ca0b49d6
commit 6992250d63
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 31 additions and 1 deletions

View file

@ -25,6 +25,7 @@ import Annex.CatFile
import qualified Data.Set as S
import Data.Either
import Data.Char
import Data.ByteString (ByteString)
import Data.ByteString.Builder
import qualified Data.ByteString.Lazy as L
@ -82,7 +83,7 @@ parseTransitionsStrictly source b =
transitionLineParser :: A.Parser TransitionLine
transitionLineParser = do
t <- (parsetransition <$> A.takeByteString)
t <- parsetransition <$> A.takeTill (== sp)
_ <- A8.char ' '
c <- vectorClockParser
return $ TransitionLine c t
@ -90,6 +91,7 @@ transitionLineParser = do
parsetransition b = case readish (decodeBS b) of
Just t -> Right t
Nothing -> Left b
sp = fromIntegral (ord ' ')
combineTransitions :: [Transitions] -> Transitions
combineTransitions = S.unions