X-Git-Url: https://git.distorted.org.uk/~mdw/qmail/blobdiff_plain/9f4f78697c369f41c86149f8ca24f8d298fc1c9f..HEAD:/qmail-remote.c diff --git a/qmail-remote.c b/qmail-remote.c index 7d65473..864dee2 100644 --- a/qmail-remote.c +++ b/qmail-remote.c @@ -189,19 +189,68 @@ char *append; zerodie(); } +stralloc verh = {0}; /* quoted recipient */ +int flagverh; /* argc */ +char *vp; /* argv[3] */ + void blast() { + unsigned int posat, i; + int flagdobody,flagheader; int r; char ch; + posat = 0; /* stays 0 if no VERH */ + flagdobody = 0; /* => 0 at first blank line */ + flagheader = 1; + if (flagverh == 4) { /* only if single recipient */ + if (!quote2(&verh,vp)) temp_nomem(); /* non-canonicalized */ + for (i = 0; i < verh.len; i++) /* \n would destroy message */ + if (verh.s[i] == '\n') verh.s[i] = '_'; + posat = byte_rchr(verh.s,verh.len,'@'); /* posat=0 if no VERH */ + if (posat == verh.len) posat = 0; + } for (;;) { r = substdio_get(&ssin,&ch,1); if (r == 0) break; if (r == -1) temp_read(); if (ch == '.') substdio_put(&smtpto,".",1); + if (flagheader) { + if (ch == '\n') { /* header ends */ + flagheader = 0; + if (!flagdobody) posat = 0; + } else if (ch == '#') { /* # starting line => VERH ... */ + flagdobody = 1; /* continues in body and ... */ + continue; /* character is suppressed. */ + } + } while (ch != '\n') { - substdio_put(&smtpto,&ch,1); + if (ch == '#' && posat) { /* ... # */ + r = substdio_get(&ssin,&ch,1); + if (r == 0) perm_partialline(); + if (r == -1) temp_read(); + if (ch == '#') { /* ... ## */ + register char ch1; + ch1 = *substdio_peek(&ssin); + if (ch1 != 'L' && ch1 != 'H') { /* ... ##x x!=L x!=H */ + substdio_put(&smtpto,"#",1); + continue; + } + r = substdio_get(&ssin,&ch,1); + if (r == 0) perm_partialline(); + if (r == -1) temp_read(); + if (ch == 'L') /* ... ##L */ + substdio_put(&smtpto,verh.s,posat); + else /* ... ##H */ + substdio_put(&smtpto,verh.s + posat + 1,verh.len - posat - 1); + } else { + substdio_put(&smtpto,"#",1); + if (ch == '\n') break; + substdio_put(&smtpto,&ch,1); + } + } else + substdio_put(&smtpto,&ch,1); r = substdio_get(&ssin,&ch,1); if (r == 0) perm_partialline(); if (r == -1) temp_read(); @@ -341,6 +390,8 @@ char **argv; sig_pipeignore(); if (argc < 4) perm_usage(); + flagverh = argc; + vp = argv[3]; if (chdir(auto_qmail) == -1) temp_chdir(); getcontrols();