diff options
author | Timo Sirainen <cras@irssi.org> | 2001-10-21 11:49:17 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-10-21 11:49:17 +0000 |
commit | 1b64509ae2bb354e2003f9263e85b8018b322404 (patch) | |
tree | 0721c5ecfe45d7f56a0548843d089593f685b812 /src | |
parent | feaee3565367c7022fcbc01c79f8e78b3c5968bc (diff) | |
download | irssi-1b64509ae2bb354e2003f9263e85b8018b322404.zip |
quitmsg_is_split() updated to check that top-level domains must be 2+ chars
and contain only alphabets.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1878 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/irc/core/netsplit.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/irc/core/netsplit.c b/src/irc/core/netsplit.c index 8542589b..85df67fd 100644 --- a/src/irc/core/netsplit.c +++ b/src/irc/core/netsplit.c @@ -216,7 +216,7 @@ NICK_REC *netsplit_find_channel(IRC_SERVER_REC *server, const char *nick, /* check if quit message is a netsplit message */ int quitmsg_is_split(const char *msg) { - const char *host1, *host2; + const char *host1, *host2, *p; int prev, len, host1_dot, host2_dot; g_return_val_if_fail(msg != NULL, FALSE); @@ -224,15 +224,12 @@ int quitmsg_is_split(const char *msg) /* NOTE: there used to be some paranoia checks (some older IRC clients have even more), but they're pretty useless nowadays, since IRC server prefixes the quit message with a space if it - looks like a quit message. - - There also used to be a check that root domain was 2-3 characters - long. This doesn't work since undernet uses now "*.net *.split" - quit message for all netsplits, and then there's the new top level - domains which breaks that code too. + looks like a netsplit message. So, the check is currently just: - host1.domain1 host2.domain2 + - top-level domains have to be 2+ characters long, + containing only alphabets - only 1 space - no double-dots (".." - probably useless check) - hosts/domains can't start or end with a dot @@ -274,7 +271,25 @@ int quitmsg_is_split(const char *msg) if (len == (int) (host2-host1)-1 && g_strncasecmp(host1, host2, len) == 0) - return FALSE; /* hosts can't be the same */ + return FALSE; /* hosts can't be the same */ + + /* top-domain1 must be 2+ chars long and contain only alphabets */ + p = host2-1; + while (p[-1] != '.') { + if (!isalpha(p[-1])) + return FALSE; + p--; + } + if (host2-p-1 < 2) return FALSE; + + /* top-domain2 must be 2+ chars long and contain only alphabets */ + p = host2+strlen(host2); + while (p[-1] != '.') { + if (!isalpha(p[-1])) + return FALSE; + p--; + } + if (strlen(p) < 2) return FALSE; return TRUE; } |