aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaro Koskinen <aaro.koskinen@iki.fi>2013-02-25 00:45:08 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2013-03-18 18:45:14 +0100
commit06ad964ae61591ef74313d7c1746367430d0d82b (patch)
treeade2d7da2e7fa06227d41deed11ab2456965d3b8
parent95e99e5271cb15247ba8926f0352387643164528 (diff)
downloadbusybox-06ad964ae61591ef74313d7c1746367430d0d82b.tar.gz
sendmail: support addresses inside angle brackets
When we extract addresses from the e-mail, try to first check for an address inside angle brackets. Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--mailutils/sendmail.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c
index 0f536adae..10a5a85d4 100644
--- a/mailutils/sendmail.c
+++ b/mailutils/sendmail.c
@@ -117,6 +117,24 @@ static char *sane_address(char *str)
return str;
}
+// check for an address inside angle brackets, if not found fall back to normal
+static char *angle_address(char *str)
+{
+ char *s = str;
+ char *e = str + strlen(str);
+
+ while (e != str && (isspace(*e) || *e == '\0'))
+ e--;
+ if (*e != '>')
+ goto done;
+ *e = '\0';
+ e = strrchr(s, '<');
+ if (e != NULL)
+ s = e + 1;
+done:
+ return sane_address(s);
+}
+
static void rcptto(const char *s)
{
if (!*s)
@@ -300,13 +318,13 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
if (opts & OPT_t) {
if (0 == strncasecmp("To:", s, 3) || 0 == strncasecmp("Bcc:" + 1, s, 3)) {
char *r = xstrdup(s+3);
- rcptto(sane_address(r));
+ rcptto(angle_address(r));
free(r);
goto addheader;
}
// Bcc: header adds blind copy (hidden) recipient
if (0 == strncasecmp("Bcc:", s, 4)) {
- rcptto(sane_address(s+4));
+ rcptto(angle_address(s+4));
free(s);
continue; // N.B. Bcc: vanishes from headers!
}