diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2021-10-14 22:18:46 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2021-10-17 21:28:31 +0200 |
commit | adcc04cc5a0b04aed753a4d1246bebd51236bf77 (patch) | |
tree | fe3fd8a972347ebeadedbea15dc3e51b71474e04 /src/plugins/irc | |
parent | e5996f626b573e955c78dd680211700b3f5f42b3 (diff) | |
download | weechat-adcc04cc5a0b04aed753a4d1246bebd51236bf77.zip |
irc: fix extraction of address from prefix
Do not return the nick when the address is missing.
Diffstat (limited to 'src/plugins/irc')
-rw-r--r-- | src/plugins/irc/irc-message.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c index b80a268d0..ceca9707f 100644 --- a/src/plugins/irc/irc-message.c +++ b/src/plugins/irc/irc-message.c @@ -634,31 +634,27 @@ irc_message_get_address_from_host (const char *host) return NULL; address[0] = '\0'; - if (host) + + ptr_host = host; + pos_space = strchr (host, ' '); + if (pos_space) { - ptr_host = host; - pos_space = strchr (host, ' '); - if (pos_space) + if (pos_space - host < (int)sizeof (host2)) { - if (pos_space - host < (int)sizeof (host2)) - { - strncpy (host2, host, pos_space - host); - host2[pos_space - host] = '\0'; - } - else - snprintf (host2, sizeof (host2), "%s", host); - ptr_host = host2; + strncpy (host2, host, pos_space - host); + host2[pos_space - host] = '\0'; } - - if (ptr_host[0] == ':') - ptr_host++; - pos = strchr (ptr_host, '!'); - if (pos) - snprintf (address, sizeof (address), "%s", pos + 1); else - snprintf (address, sizeof (address), "%s", ptr_host); + snprintf (host2, sizeof (host2), "%s", host); + ptr_host = host2; } + if (ptr_host[0] == ':') + ptr_host++; + pos = strchr (ptr_host, '!'); + if (pos) + snprintf (address, sizeof (address), "%s", pos + 1); + return address; } |