*really* fix quoting in phrase part of addresses; eliminate #-style
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sat, 14 Nov 1992 08:04:22 +0000 (00:04 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sat, 14 Nov 1992 08:04:22 +0000 (00:04 -0800)
commenting in :include: and .forward files (parenthesized comments
can be used instead)

SCCS-vsn: usr.sbin/sendmail/src/headers.c 5.23
SCCS-vsn: usr.sbin/sendmail/src/recipient.c 5.36
SCCS-vsn: usr.sbin/sendmail/src/version.c 5.121
SCCS-vsn: usr.sbin/sendmail/src/util.c 5.31

usr/src/usr.sbin/sendmail/src/headers.c
usr/src/usr.sbin/sendmail/src/recipient.c
usr/src/usr.sbin/sendmail/src/util.c
usr/src/usr.sbin/sendmail/src/version.c

index 88b29e3..217f61f 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)headers.c  5.22 (Berkeley) %G%";
+static char sccsid[] = "@(#)headers.c  5.23 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <sys/param.h>
 #endif /* not lint */
 
 # include <sys/param.h>
@@ -45,7 +45,6 @@ chompheader(line, def, e)
        struct hdrinfo *hi;
        bool cond = FALSE;
        BITMAP mopts;
        struct hdrinfo *hi;
        bool cond = FALSE;
        BITMAP mopts;
-       extern char *crackaddr();
        extern ADDRESS *sendto();
 
        if (tTd(31, 6))
        extern ADDRESS *sendto();
 
        if (tTd(31, 6))
@@ -464,6 +463,7 @@ crackaddr(addr)
        int copylev;
        bool qmode;
        bool putgmac = FALSE;
        int copylev;
        bool qmode;
        bool putgmac = FALSE;
+       bool quoteit = FALSE;
        register char *bp;
        static char buf[MAXNAME];
 
        register char *bp;
        static char buf[MAXNAME];
 
@@ -489,6 +489,20 @@ crackaddr(addr)
                if (copylev > 0 || c == ' ')
                        *bp++ = c;
 
                if (copylev > 0 || c == ' ')
                        *bp++ = c;
 
+               /* check for characters that may have to be quoted */
+               if (index(".'@,;:[]", c) != NULL)
+               {
+                       /*
+                       **  If these occur as the phrase part of a <>
+                       **  construct, but are not inside of () or already
+                       **  quoted, they will have to be quoted.  Note that
+                       **  now (but don't actually do the quoting).
+                       */
+
+                       if (cmtlev <= 0 && !qmode)
+                               quoteit = TRUE;
+               }
+
                /* check for backslash escapes */
                if (c == '\\')
                {
                /* check for backslash escapes */
                if (c == '\\')
                {
@@ -532,11 +546,35 @@ crackaddr(addr)
                /* check for angle brackets */
                if (c == '<')
                {
                /* check for angle brackets */
                if (c == '<')
                {
+                       register char *q;
+
                        /* oops -- have to change our mind */
                        /* oops -- have to change our mind */
-                       bcopy(addr, buf, p - addr);
-                       bp = &buf[p - addr];
+                       bp = buf;
+                       if (quoteit)
+                       {
+                               *bp++ = '"';
+
+                               /* back up over the '<' and any spaces */
+                               --p;
+                               while (isspace(*--p))
+                                       continue;
+                               p++;
+                       }
+                       for (q = addr; q < p; )
+                       {
+                               c = *q++;
+                               if (quoteit && c == '"')
+                                       *bp++ = '\\';
+                               *bp++ = c;
+                       }
+                       if (quoteit)
+                       {
+                               *bp++ = '"';
+                               while ((*bp++ = *p++) != '<')
+                                       continue;
+                       }
                        copylev = 0;
                        copylev = 0;
-                       putgmac = FALSE;
+                       putgmac = quoteit = FALSE;
                        continue;
                }
 
                        continue;
                }
 
index aaeb70e..7799b62 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)recipient.c        5.35 (Berkeley) %G%";
+static char sccsid[] = "@(#)recipient.c        5.36 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <sys/types.h>
 #endif /* not lint */
 
 # include <sys/types.h>
@@ -723,8 +723,6 @@ include(fname, forwarding, ctladdr, sendq, e)
                LineNumber++;
                if (p != NULL)
                        *p = '\0';
                LineNumber++;
                if (p != NULL)
                        *p = '\0';
-               if (buf[0] == '\0' || buf[0] == '#')
-                       continue;
                e->e_to = oldto;
                message(Arpa_Info, "%s to %s",
                        forwarding ? "forwarding" : "sending", buf);
                e->e_to = oldto;
                message(Arpa_Info, "%s to %s",
                        forwarding ? "forwarding" : "sending", buf);
index ed86a48..6811164 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)util.c     5.30 (Berkeley) %G%";
+static char sccsid[] = "@(#)util.c     5.31 (Berkeley) %G%";
 #endif /* not lint */
 
 # include <stdio.h>
 #endif /* not lint */
 
 # include <stdio.h>
@@ -344,7 +344,6 @@ fullname(pw, buf)
        register char *p;
        register char *bp = buf;
        int l;
        register char *p;
        register char *bp = buf;
        int l;
-       bool quoteit;
        register char *p = pw->pw_gecos;
 
        if (*gecos == '*')
        register char *p = pw->pw_gecos;
 
        if (*gecos == '*')
@@ -352,22 +351,15 @@ fullname(pw, buf)
 
        /* see if the full name needs to be quoted */
        l = 0;
 
        /* see if the full name needs to be quoted */
        l = 0;
-       quoteit = FALSE;
        for (p = gecos; *p != '\0' && *p != ',' && *p != ';' && *p != '%'; p++)
        {
        for (p = gecos; *p != '\0' && *p != ',' && *p != ';' && *p != '%'; p++)
        {
-               if (index("<>()'.", *p) != NULL)
-                       quoteit = TRUE;
                if (*p == '&')
                        l += strlen(login);
                else
                        l++;
        }
                if (*p == '&')
                        l += strlen(login);
                else
                        l++;
        }
-       if (quoteit)
-               l += 2;
 
        /* now fill in buf */
 
        /* now fill in buf */
-       if (quoteit)
-               *bp++ = '"';
        for (p = gecos; *p != '\0' && *p != ',' && *p != ';' && *p != '%'; p++)
        {
                if (*p == '&')
        for (p = gecos; *p != '\0' && *p != ',' && *p != ';' && *p != '%'; p++)
        {
                if (*p == '&')
@@ -380,8 +372,6 @@ fullname(pw, buf)
                else
                        *bp++ = *p;
        }
                else
                        *bp++ = *p;
        }
-       if (quoteit)
-               *bp++ = '"';
        *bp = '\0';
 }
 \f/*
        *bp = '\0';
 }
 \f/*
index 88e09fc..6a60f9b 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)version.c  5.120 (Berkeley) %G%";
+static char sccsid[] = "@(#)version.c  5.121 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-char   Version[] = "5.120";
+char   Version[] = "5.121";