]> Pileus Git - ~andy/fetchmail/commitdiff
Stricter hostname parsing.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 13 Jan 1997 03:09:56 +0000 (03:09 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 13 Jan 1997 03:09:56 +0000 (03:09 -0000)
svn path=/trunk/; revision=748

driver.c

index c7aa4dd0266e8ef21d0bfb69e6604a2644804c33..ac79c64abeb171df18b78e27dd2215f8cbc20abb 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -971,46 +971,60 @@ const struct method *proto;       /* protocol method table */
         * This assumes that the first space-delimited token found
         * that contains at least two dots (with the characters on
         * each side of the dot alphanumeric to exclude version
-        * numbers) is the hostname.  If no such token is found, fall
-        * back on the .fetchmailrc id.  */
+        * numbers) is the hostname.  The hostname candidate may not
+        * contain @ -- if it does it's probably a mailserver
+        * maintainer's name.  If no such token is found, fall back on
+        * the .fetchmailrc id.
+        */
        pst = 0;
        for (cp = buf; *cp; cp++)
        {
            switch (pst)
            {
-           case 0:             /* looking for blank-delimited token */
+           case 0:             /* skip to end of current token */
+               if (*cp == ' ')
+                   pst = 1;
+               break;
+
+           case 1:             /* look for blank-delimited token */
                if (*cp != ' ')
                {
                    sp = cp;
-                   pst = 1;
+                   pst = 2;
                }
                break;
 
-           case 1:             /* looking for first dot */
-               if (*cp == ' ')
+           case 2:             /* look for first dot */
+               if (*cp == '@')
                    pst = 0;
+               else if (*cp == ' ')
+                   pst = 1;
                else if (*cp == '.' && isalpha(cp[1]) && isalpha(cp[-1]))
-                   pst = 2;
+                   pst = 3;
                break;
 
-           case 2:             /* looking for second dot */
-               if (*cp == ' ')
+           case 3:             /* look for second dot */
+               if (*cp == '@')
                    pst = 0;
+               else if (*cp == ' ')
+                   pst = 1;
                else if (*cp == '.' && isalpha(cp[1]) && isalpha(cp[-1]))
-                   pst = 3;
+                   pst = 4;
                break;
 
-           case 3:             /* looking for trailing space */
-               if (*cp == ' ')
+           case 4:             /* look for trailing space */
+               if (*cp == '@')
+                   pst = 0;
+               else if (*cp == ' ')
                {
-                   pst = 4;
+                   pst = 5;
                    goto done;
                }
                break;
            }
        }
     done:
-       if (pst == 4)
+       if (pst == 5)
        {
            char        *tp = realname;