mirror of
https://github.com/chrisdone/ini.git
synced 2025-01-05 05:19:17 +03:00
Fail parsing if the input isn't completely consumed
Without this, parsing stops at the start of any invalid input and returns a successful result Closes #29
This commit is contained in:
parent
0c773d8ed8
commit
17659d59c2
@ -245,7 +245,8 @@ iniParser :: Parser Ini
|
||||
iniParser =
|
||||
(\kv secs -> Ini {iniSections = M.fromList secs, iniGlobals = kv}) <$>
|
||||
many keyValueParser <*>
|
||||
many sectionParser
|
||||
many sectionParser <*
|
||||
(endOfInput <|> (fail . T.unpack =<< takeWhile (not . isControl)))
|
||||
|
||||
-- | A section. Format: @[foo]@. Conventionally, @[FOO]@.
|
||||
sectionParser :: Parser (Text,[(Text, Text)])
|
||||
|
@ -64,4 +64,11 @@ main =
|
||||
]
|
||||
, iniGlobals =
|
||||
[("port", "6667"), ("hostname", "localhost")]
|
||||
})))))
|
||||
})))
|
||||
it
|
||||
"File with invalid keys"
|
||||
(shouldBe
|
||||
(parseIni
|
||||
"Name=Foo\n\
|
||||
\Name[en_GB]=Fubar")
|
||||
(Left "Failed reading: Name[en_GB]=Fubar"))))
|
||||
|
Loading…
Reference in New Issue
Block a user