ref: 4ac3a0224ed9d54818f858fba69c8e94f38f2c12
dir: /9front/863b4ae53732ddeaf96dc23b0e9924651f2b4090.patch/
From: Romano <[email protected]> Date: Fri, 17 May 2024 08:08:34 +0000 Subject: [PATCH] upas/send: parse e-mail descriptions like marshal /sys/src/cmd/upas/marshal/marshal.c:/^printfrom parses an e-mail with a description (e.g., "A Name <[email protected]>") and sets the from to just the e-mail address portion. This does the same for upas/send so that upasname='A name <[email protected]>' can be used to both set the From: in marshal with a description and to match the correct from in upas/send for sending via smtp. --- diff e51d4aa069548de51d0e88a6d621d278e9138cd0 863b4ae53732ddeaf96dc23b0e9924651f2b4090 --- a/sys/src/cmd/upas/send/message.c +++ b/sys/src/cmd/upas/send/message.c @@ -1,6 +1,7 @@ #include "common.h" #include "send.h" #include <regexp.h> +#include <ctype.h> #include "../smtp/smtp.h" #include "../smtp/rfc822.tab.h" @@ -18,6 +19,23 @@ static String* getstring(Node *p); static String* getaddr(Node *p); +char * +userfrom(char *cp) +{ + char *s; + int n; + + if((n = strlen(cp)) > 4 && cp[n-1] == '>'){ + if((s = strrchr(cp, '<')) != nil && s != cp && isspace(s[-1])) { + s++; + cp[n-1] = '\0'; + strcpy(cp, s); + } + } + + return cp; +} + int default_from(message *mp) { @@ -32,7 +50,7 @@ return -1; } if(cp && *cp) - s_append(mp->sender, cp); + s_append(mp->sender, userfrom(cp)); else s_append(mp->sender, lp); free(cp);