mirror of
https://github.com/chrisdone/ini.git
synced 2024-11-29 11:32:11 +03:00
Merge pull request #30 from neilmayhew/detect-invalid-input
Detect invalid input
This commit is contained in:
commit
61d581ad00
@ -75,7 +75,6 @@ import Data.Char
|
||||
import Data.HashMap.Strict (HashMap)
|
||||
import qualified Data.HashMap.Strict as M
|
||||
import Data.Maybe
|
||||
import Data.Monoid (Monoid)
|
||||
import Data.Semigroup
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
@ -246,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)])
|
||||
|
@ -1,7 +1,7 @@
|
||||
# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md
|
||||
|
||||
# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
|
||||
resolver: lts-11.2
|
||||
resolver: lts-16.31
|
||||
|
||||
# Local packages, usually specified by relative directory name
|
||||
packages:
|
||||
|
@ -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