email-validate 2.1.1 → 2.1.2
raw patch · 3 files changed
+15/−12 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- email-validate.cabal +2/−2
- src/Text/Email/Parser.hs +6/−8
- tests/Main.hs +7/−2
email-validate.cabal view
@@ -1,5 +1,5 @@ name: email-validate -version: 2.1.1 +version: 2.1.2 license: BSD3 license-file: LICENSE author: George Pollard <porges@porg.es> @@ -19,7 +19,7 @@ source-repository this type: git location: git://github.com/Porges/email-validate-hs.git - tag: v2.1.1 + tag: v2.1.2 library build-depends:
src/Text/Email/Parser.hs view
@@ -29,14 +29,12 @@ show = show . toByteString instance Read EmailAddress where - readsPrec _ ('"':s) = go (parse addrSpec $ BS.pack s) where - go (Fail _ _ _) = [] - go (Partial f) = go (f BS.empty) - go (Done r adr) = - case BS.unpack r of - ('"':r') -> [(adr, r')] - _ -> [] - readsPrec _ _ = [] + readListPrec = Read.readListPrecDefault + readPrec = Read.parens (do + bs <- Read.readPrec + case parseOnly (addrSpec <* endOfInput) bs of + Left _ -> Read.pfail + Right a -> return a) -- | Converts an email address back to a ByteString toByteString :: EmailAddress -> ByteString
tests/Main.hs view
@@ -1,6 +1,5 @@ module Main where - import Text.Email.Validate import Test.HUnit @@ -23,16 +22,22 @@ testProperty "showAndReadBackWithoutQuoteFails" prop_showAndReadBackWithoutQuoteFails, testProperty "showAndReadBack" prop_showAndReadBack ], + testGroup "QuickCheck Text.Email.Validate" [ testProperty "doubleCanonicalize" prop_doubleCanonicalize ], + testGroup "Unit tests Text.Email.Validate" $ flip concatMap units (\(em, valid, _) -> let email = BS.pack em in [ testCase ("doubleCanonicalize '" ++ em ++ "'") (True @=? case emailAddress email of { Nothing -> True; Just ok -> prop_doubleCanonicalize ok }), testCase ("validity test '" ++ em ++ "'") (valid @=? isValid email) - ]) + ]), + + testGroup "Issues" [ + testCase "#12" (let (Right em) = validate (BS.pack "\"\"@1") in em @=? read (show em)) + ] ] instance Arbitrary ByteString where