diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1997-01-13 03:09:56 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1997-01-13 03:09:56 +0000 |
commit | d03d9e96324f081292d0191ecac8a35b44e8dcc6 (patch) | |
tree | e22459016209c78a80fcece77f68b5d1049822d9 | |
parent | 7361ad96ef3689cff51fae0e866fa635c47a1215 (diff) | |
download | fetchmail-d03d9e96324f081292d0191ecac8a35b44e8dcc6.tar.gz fetchmail-d03d9e96324f081292d0191ecac8a35b44e8dcc6.tar.bz2 fetchmail-d03d9e96324f081292d0191ecac8a35b44e8dcc6.zip |
Stricter hostname parsing.
svn path=/trunk/; revision=748
-rw-r--r-- | driver.c | 42 |
1 files changed, 28 insertions, 14 deletions
@@ -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; |