Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPv4 address with mask should not contain a white space #64

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Data/IP/Addr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@
_ <- char '.'
a3 <- octet
let as = [a0, a1, a2, a3]
skipSpaces
when checkTermination termination
when checkTermination $
skipSpaces >> termination
return as

skipSpaces :: Parser ()
Expand Down Expand Up @@ -632,7 +632,7 @@
ipv4ToIPv6 :: IPv4 -> IPv6
ipv4ToIPv6 ip = toIPv6b [0,0,0,0,0,0,0,0,0,0,0xff,0xff,i1,i2,i3,i4]
where
[i1,i2,i3,i4] = fromIPv4 ip

Check warning on line 635 in Data/IP/Addr.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 9.2)

Pattern match(es) are non-exhaustive

Check warning on line 635 in Data/IP/Addr.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 9.2)

Pattern match(es) are non-exhaustive

Check warning on line 635 in Data/IP/Addr.hs

View workflow job for this annotation

GitHub Actions / build (macOS-latest, 9.2)

Pattern match(es) are non-exhaustive

Check warning on line 635 in Data/IP/Addr.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest, 9.2)

Pattern match(es) are non-exhaustive

-- | Convert 'SockAddr' to 'IP'.
--
Expand Down
5 changes: 4 additions & 1 deletion test/IPSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading