From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api v2 1/2] partially fix #2795: allow for '>' in smtp parameters
Date: Thu, 25 Nov 2021 13:03:03 +0100 [thread overview]
Message-ID: <20211125120304.122388-2-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20211125120304.122388-1-s.ivanov@proxmox.com>
The regular expressions parsing the MAIL and RCPT commands do not
cover the case where a esmtp parameter may contain angle brackets
(e.g. the ENVID parameter for the delivery status notification
extension - RFC3464 [0]).
following section 4.1.2 of RFC5321 [1] the regex is changed to:
* consider everything up to the first '>' the mailbox
* consider everything afterwards (if it starts with a ' ') as
parameters
This is fairly robusts, only not parsing correctly if the local part
contains '>' (as quoted text) - but this did not work before anyways
(and causes problems in other places as well).
tested with:
```
cat test.eml | /usr/sbin/sendmail -N success,delay,failure \
-V '<someid@somehost>' \
-f '"local>part"@test.example' \
discard@test.example
```
[0] https://tools.ietf.org/html/rfc3464
[1] https://tools.ietf.org/html/rfc5321#section-4.1.2
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
src/PMG/SMTP.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/PMG/SMTP.pm b/src/PMG/SMTP.pm
index 68c833e..24cce23 100644
--- a/src/PMG/SMTP.pm
+++ b/src/PMG/SMTP.pm
@@ -100,7 +100,7 @@ sub loop {
$self->reply ("250 2.5.0 OK");
next;
} elsif ($cmd eq 'mail') {
- if ($args =~ m/^from:\s*<([^\s\>]*)>([^>]*)$/i) {
+ if ($args =~ m/^from:\s*<([^\s\>]*?)>( .*)$/i) {
delete $self->{to};
my ($from, $opts) = ($1, $2);
if ($opts =~ m/\sSMTPUTF8/) {
@@ -115,7 +115,7 @@ sub loop {
next;
}
} elsif ($cmd eq 'rcpt') {
- if ($args =~ m/^to:\s*<([^\s\>]+)>[^>]*$/i) {
+ if ($args =~ m/^to:\s*<([^\s\>]+?)>( .*)$/i) {
my $to = $self->{smtputf8} ? decode('UTF-8', $1) : $1;
push @{$self->{to}} , $to;
$self->reply ('250 2.5.0 OK');
--
2.30.2
next prev parent reply other threads:[~2021-11-25 12:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 12:03 [pmg-devel] [PATCH pmg-api v2 0/2] fix #2795 - add DSN support Stoiko Ivanov
2021-11-25 12:03 ` Stoiko Ivanov [this message]
2021-11-25 12:03 ` [pmg-devel] [PATCH pmg-api v2 2/2] fix #2795: add support for DSN Stoiko Ivanov
2021-11-25 15:02 ` [pmg-devel] [PATCH pmg-api v2 0/2] fix #2795 - add DSN support Dominik Csapak
2021-11-26 10:10 ` Dominik Csapak
2021-11-26 10:40 ` Dominik Csapak
2021-11-26 11:57 ` Stoiko Ivanov
2021-11-26 11:02 ` [pmg-devel] applied-series: " Stoiko Ivanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211125120304.122388-2-s.ivanov@proxmox.com \
--to=s.ivanov@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox