From b77f219c40b0b3552b7693bfeca13a3490177dd1 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Tue, 30 Jan 2024 02:56:41 +0100 Subject: [PATCH] WIP: RFC5322, actually almost everything works! --- src/GenericParser/EmailAddress.purs | 2 +- test/Main.purs | 3 +++ test/TestValues.purs | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/GenericParser/EmailAddress.purs b/src/GenericParser/EmailAddress.purs index f4b6ec6..6a22e62 100644 --- a/src/GenericParser/EmailAddress.purs +++ b/src/GenericParser/EmailAddress.purs @@ -281,7 +281,7 @@ domain_literal = do _ <- tryMaybe cfws _ <- tryMaybe fws _ <- char ']' _ <- tryMaybe cfws - pure $ A.fold xs + pure $ "[" <> A.fold xs <> "]" -- | dtext: characters in domains. -- | diff --git a/test/Main.purs b/test/Main.purs index 081b453..ef65d23 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -80,3 +80,6 @@ main = do log "" test_series "E.email" E.email id showerror_email T.valid_email_addresses + + log "" + test_series "E.address (short)" E.address id showerror_email T.valid_email_addresses_short diff --git a/test/TestValues.purs b/test/TestValues.purs index cb75c16..029d397 100644 --- a/test/TestValues.purs +++ b/test/TestValues.purs @@ -44,6 +44,27 @@ ipv6_addresses , "2001:0db8::8a2e:0370:7334" ] +valid_email_addresses_short :: Array String +valid_email_addresses_short + = [ """simple@example.com""" + , """very.common@example.com""" + , """x@example.com """ + , """long.email-address-with-hyphens@and.subdomains.example.com""" + , """user.name+tag+sorting@example.com """ + , """name/surname@example.com """ + , """admin@example """ + , """example@s.example """ + , """" "@example.org """ + , """"john..doe"@example.org """ + , """mailhost!username@example.org """ + , """"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com """ + , """user%example.com@example.org """ + , """user-@example.org """ + , """postmaster@[123.123.123.123] """ + , """postmaster@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334] """ + , """_test@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334] """ + ] + valid_email_addresses :: Array String valid_email_addresses = [ """simple@example.com"""