From ca0520a33c9042a68691d85c6849f88412ca8357 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 15 Mar 2021 01:51:43 +0530 Subject: email: Use only cfws-captured-words in obs-phrase. * email/email.scm (obs-phrase): Replace word with cfws-captured-word. * tests/email.scm ("Parse names with more than two words"): New test. --- email/email.scm | 4 ++-- tests/email.scm | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/email/email.scm b/email/email.scm index 631d519..3f4e194 100644 --- a/email/email.scm +++ b/email/email.scm @@ -1,5 +1,5 @@ ;;; guile-email --- Guile email parser -;;; Copyright © 2018, 2019, 2020 Arun Isaac +;;; Copyright © 2018, 2019, 2020, 2021 Arun Isaac ;;; ;;; This file is part of guile-email. ;;; @@ -224,7 +224,7 @@ (define-word-pattern cfws-captured-word cfws-captured-atom) (define-peg-pattern obs-phrase body - (and cfws-captured-word (* (or "." cfws word)))) + (and cfws-captured-word (* (or cfws-captured-word "." cfws)))) ;; We set phrase to be the same as obs-phrase since, according to ;; their definitions in RFC5322, all phrases are obs-phrases. diff --git a/tests/email.scm b/tests/email.scm index 83ef91f..469389a 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 Arun Isaac +;;; Copyright © 2018, 2019, 2020, 2021 Arun Isaac ;;; ;;; This file was adapted from guile-debbugs and is part of guile-email. ;;; @@ -507,6 +507,17 @@ Received: from zzz ([1.2.3.5]) by ooo.ooo.com with Maccrosoft SMTPSVC(5.5.1877. (charset . "utf-8")) (content-transfer-encoding . 7bit))) +(test-alist= "Parse names with more than two words" + (parse-email-headers + "From: Foo Bar Foobar +") + `((from ((name . "Foo Bar Foobar") + (address . "foo@bar.org"))) + (content-type (type . text) + (subtype . plain) + (charset . "utf-8")) + (content-transfer-encoding . 7bit))) + (test-equal "parse name-addr email address" (parse-email-address "Foo ") '((name . "Foo") (address . "foo@example.org"))) -- cgit v1.2.3