-- (octets).
--
module Network.DNS.RBL.Domain (
- UserDomain,
+ UserDomain(..),
user_domain )
where
-- letter or a digit. Host software MUST support this more liberal
-- syntax.
--
-data Label = Label Letter (Maybe LdhStrLetDig)
+data Label = Label LetDig (Maybe LdhStrLetDig)
deriving (Eq, Show)
instance Pretty Label where
-- Make sure we can parse a single character:
--
-- >>> parseTest label "a"
--- Label (Letter 'a') Nothing
+-- Label (LetDigLetter (Letter 'a')) Nothing
--
-- And longer strings:
--
-- >>> pretty_print $ parse label "" (replicate 63 'x')
-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
--
+-- Ensure that a label can begin with a digit:
+--
+-- >>> pretty_print $ parse label "" "3com"
+-- 3com
+--
label :: Parser Label
label = do
- l <- letter -- Guaranteed to be there
+ l <- let_dig -- Guaranteed to be there
maybe_s <- optionMaybe ldh_str_let_dig -- Might not be there
case maybe_s of
-- It can only be one character long, from the letter...
-- Make sure we can parse a single character:
--
-- >>> parseTest subdomain "a"
--- SubdomainSingleLabel (Label (Letter 'a') Nothing)
+-- SubdomainSingleLabel (Label (LetDigLetter (Letter 'a')) Nothing)
--
-- >>> pretty_print $ parse subdomain "" "example.com"
-- example.com
--
-- Make sure we can parse a single character:
--
--- >>> parseTest domain "a"
--- DomainName (SubdomainSingleLabel (Label (Letter 'a') Nothing))
+-- >>> pretty_print $ parse domain "" "a"
+-- a
--
-- And the empty domain:
--
-- We will in fact parse the \"empty\" domain off the front of
-- pretty much anything:
--
--- >>> parseTest domain "8===D"
+-- >>> parseTest domain "!8===D"
-- DomainRoot
--
-- Equality of domains is case-insensitive: