diff --git a/Data/IP/Addr.hs b/Data/IP/Addr.hs index 511c9b8..a5da4a1 100644 --- a/Data/IP/Addr.hs +++ b/Data/IP/Addr.hs @@ -512,8 +512,8 @@ ip4' checkTermination = do _ <- char '.' a3 <- octet let as = [a0, a1, a2, a3] - skipSpaces - when checkTermination termination + when checkTermination $ + skipSpaces >> termination return as skipSpaces :: Parser () diff --git a/test/IPSpec.hs b/test/IPSpec.hs index b547561..cf97d0e 100644 --- a/test/IPSpec.hs +++ b/test/IPSpec.hs @@ -24,8 +24,11 @@ data InvalidIPv4Str = Iv4 String deriving (Show) instance Arbitrary InvalidIPv4Str where arbitrary = - frequency [(9, arbitraryIIPv4Str arbitrary 32) + frequency [(8, arbitraryIIPv4Str arbitrary 32) + -- an IPv4 address should not end with a trailing `.` ,(1, Iv4 . (++ ".") . show <$> genIPv4) + -- an IPv4 address with mask should not include a white space + ,(1, (\ip (NonNegative len) -> Iv4 (show ip ++ " /" ++ show (len :: Integer))) <$> genIPv4 <*> arbitrary) ] where genIPv4 :: Gen IPv4