From 9a82ce70b9eded77a148336feb8913156a31bab8 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 9 Feb 2025 22:08:22 +0000 Subject: email: Tolerate square brackets in email addresses. * email/email.scm (liberal-atext): Add [ and ]. * tests/email.scm ("tolerate email addresses with square brackets in name"): New test. --- email/email.scm | 6 +++--- tests/email.scm | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/email/email.scm b/email/email.scm index a29a532..ff0f5e9 100644 --- a/email/email.scm +++ b/email/email.scm @@ -1,5 +1,5 @@ ;;; guile-email --- Guile email parser -;;; Copyright © 2018, 2019, 2020, 2021, 2023 Arun Isaac +;;; Copyright © 2018, 2019, 2020, 2021, 2023, 2025 Arun Isaac ;;; Copyright © 2021 Mathieu Othacehe ;;; Copyright © 2023 Andrew Whatson ;;; @@ -360,9 +360,9 @@ ;; MUAs tend to pass on these non-standard names without any ;; quoting. Tolerate such names. -;; Tolerate non-standard ( and ) in atext. +;; Tolerate non-standard (, ), [ and ] in atext. (define-peg-pattern liberal-atext body - (or atext "(" ")")) + (or atext "(" ")" "[" "]")) (define-atom-pattern liberal-cfws-captured-atom cfws liberal-atext) (define-word-pattern liberal-cfws-captured-word liberal-cfws-captured-atom) diff --git a/tests/email.scm b/tests/email.scm index dd305b6..972233d 100644 --- a/tests/email.scm +++ b/tests/email.scm @@ -1,6 +1,6 @@ ;;; guile-email --- Guile email parser ;;; Copyright © 2017 Ricardo Wurmus -;;; Copyright © 2018, 2019, 2020, 2021, 2023 Arun Isaac +;;; Copyright © 2018, 2019, 2020, 2021, 2023, 2025 Arun Isaac ;;; Copyright © 2023 Andrew Whatson ;;; ;;; This file was adapted from guile-debbugs and is part of guile-email. @@ -594,6 +594,10 @@ Content-Type: text/plain; charset=utf-8 (parse-email-address "Foo(Bar ") '((name . "Foo(Bar") (address . "foo@example.com"))) +(test-equal "tolerate email addresses with square brackets in name" + (parse-email-address "Foo [Bar] ") + '((name . "Foo [Bar]") (address . "foo@example.com"))) + ;;; ;;; MIME encoded words -- cgit v1.2.3