X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/0f4b9af077461d8098f6868c69243551e6f500ee..e9d39f548915dfaeb5dee56dd3bf0d9d81bf9780:/sbr/mf.c diff --git a/sbr/mf.c b/sbr/mf.c index f993c235..e2da81d0 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -8,14 +8,11 @@ */ #include -#include -#include #include /* * static prototypes */ -static char *getcpy (const char *); static int isat (const char *); static int parse_address (void); static int phrase (char *); @@ -26,25 +23,6 @@ static int route (char *); static int my_lex (char *); -static char * -getcpy (const char *s) -{ - register char *p; - - if (!s) { -/* causes compiles to blow up because the symbol _cleanup is undefined - where did this ever come from? */ - /* _cleanup(); */ - abort(); - for(;;) - pause(); - } - p = mh_xmalloc ((size_t) (strlen (s) + 2)); - strcpy (p, s); - return p; -} - - int isfrom(const char *string) { @@ -87,7 +65,7 @@ isat (const char *p) * getadrx() implements a partial 822-style address parser. The parser * is neither complete nor correct. It does however recognize nearly all * of the 822 address syntax. In addition it handles the majority of the - * 733 syntax as well. Most problems arise from trying to accomodate both. + * 733 syntax as well. Most problems arise from trying to accommodate both. * * In terms of 822, the route-specification in * @@ -196,11 +174,12 @@ static char adr[BUFSIZ]; static struct adrx adrxs2; +/* eai = Email Address Internationalization */ struct adrx * -getadrx (const char *addrs) +getadrx (const char *addrs, int eai) { - register char *bp; - register struct adrx *adrxp = &adrxs2; + char *bp; + struct adrx *adrxp = &adrxs2; if (pers) free (pers); @@ -218,7 +197,7 @@ getadrx (const char *addrs) err[0] = 0; if (dp == NULL) { - dp = cp = getcpy (addrs ? addrs : ""); + dp = cp = strdup (addrs ? addrs : ""); glevel = 0; } else @@ -252,6 +231,17 @@ getadrx (const char *addrs) break; } + if (! eai) { + /* + * Reject the address if key fields contain 8bit characters + */ + + if (contains8bit(mbox, NULL) || contains8bit(host, NULL) || + contains8bit(path, NULL) || contains8bit(grp, NULL)) { + strcpy(err, "Address contains 8-bit characters"); + } + } + if (err[0]) for (;;) { switch (last_lex) { @@ -299,7 +289,7 @@ again: ; switch (my_lex (buffer)) { case LX_ATOM: case LX_QSTR: - pers = getcpy (buffer); + pers = strdup (buffer); break; case LX_SEMI: @@ -459,7 +449,7 @@ phrase (char *buffer) static int route_addr (char *buffer) { - register char *pp = cp; + char *pp = cp; if (my_lex (buffer) == LX_AT) { if (route (buffer) == NOTOK) @@ -553,7 +543,7 @@ domain (char *buffer) static int route (char *buffer) { - path = getcpy ("@"); + path = strdup ("@"); for (;;) { switch (my_lex (buffer)) { @@ -652,7 +642,7 @@ my_lex (char *buffer) if (--i < 0) { *bp = 0; note = note ? add (buffer, add (" ", note)) - : getcpy (buffer); + : strdup (buffer); return my_lex (buffer); } } @@ -744,7 +734,7 @@ char * legal_person (const char *p) { int i; - register const char *cp; + const char *cp; static char buffer[BUFSIZ]; if (*p == '"') @@ -764,7 +754,7 @@ int mfgets (FILE *in, char **bp) { int i; - register char *cp, *dp, *ep; + char *cp, *dp, *ep; static int len = 0; static char *pp = NULL;