Enable domain wildcards.

This commit is contained in:
Philippe Pittoli 2025-04-27 17:41:11 +02:00
parent 0684286805
commit 6550b3f354
3 changed files with 25 additions and 2 deletions

View file

@ -73,10 +73,21 @@ sub_eof = do
-- | From RFC 1035: <domain> ::= <subdomain> | " "
-- |
-- | Since RFC 1034 requires to accept '*' as leftmost domain label, the rule should be:
-- | <domain> ::= <subdomain> | "*." <subdomain> | " "
-- |
-- | Accepting an optional '.' at the end of the subdomain doesn't conform
-- | to the (prefered) syntax of a domain as described in RFC 1035.
-- | However, this last '.' character should be acceptable in most applications.
-- | In some cases, a fully qualified domain name (FQDN) such as `example.com.`
-- | has to be differenciated from a "relative" name (www).
-- |
-- | For documentation about wildcards, see RFC 4592.
domain :: Parser DomainError String
domain = (string " " *> eof) <|> sub_eof
domain = (string " " *> eof) <|> wildcard <|> sub_eof
where
wildcard :: Parser DomainError String
wildcard = do
_ <- string "*."
rest <- sub_eof
pure $ "*." <> rest

View file

@ -79,10 +79,21 @@ sub_eof = do
-- | From RFC 1035: <domain> ::= <subdomain> | " "
-- |
-- | Since RFC 1034 requires to accept '*' as leftmost domain label, the rule should be:
-- | <domain> ::= <subdomain> | "*." <subdomain> | " "
-- |
-- | Accepting an optional '.' at the end of the subdomain doesn't conform
-- | to the (prefered) syntax of a domain as described in RFC 1035.
-- | However, this last '.' character should be acceptable in most applications.
-- | In some cases, a fully qualified domain name (FQDN) such as `example.com.`
-- | has to be differenciated from a "relative" name (www).
-- |
-- | For documentation about wildcards, see RFC 4592.
domain :: Parser DomainError String
domain = (string " " *> eof) <|> sub_eof
domain = (string " " *> eof) <|> wildcard <|> sub_eof
where
wildcard :: Parser DomainError String
wildcard = do
_ <- string "*."
rest <- sub_eof
pure $ "*." <> rest

View file

@ -15,6 +15,7 @@ domains
, "xblah.a2.org"
, "xblah.a33.org"
, "_dmarc.example.com"
, "*.example.com"
]
ipv4_addresses :: Array String