Subject: rcirc: ERR_NICKNAMEINUSE causes infinite loop under certain circumstances

From: Deniz Dogan <[email-masked]>
Date: Wed, 4 Aug 2010 19:55:21 +0200

Currently rcirc-handler-433 (ERR_NICKNAMEINUSE) tries to "uniquify"
the nickname the user tried to use by appeding a ` to the requested
nickname. However, if the length of the requested nickname is as long
as or longer than the maximum allowed length on the server, the
"uniquification" will not work resulting in an attempt to switch to
the same nickname that caused the error in the first place:

Example:
/nick superlongnickname
*** 433 superlongn Nickname is already in use.

Here the IRC server truncates the requested nickname to "superlongn"
which is already taken and then it tries to change to
"superlongnickname`" which of course will also be truncated to
"superlongn". Hence, something like this will be printed in the server
buffer:

*** 433 superlongn Nickname is already in use.
*** 433 superlongn Nickname is already in use.
*** 433 superlongn Nickname is already in use.
*** 433 superlongn Nickname is already in use.

...and so on.

The maximum nickname length of the server is received in a 005 message
from the server when connecting. Example (NICKLEN=16):

*** 005 SAFELIST ELIST=U CASEMAPPING=rfc1459 CHARSET=ascii NICKLEN=16
    CHANNELLEN=50 TOPICLEN=390 ETRACE CPRIVMSG CNOTICE DEAF=D
    MONITOR=100 are supported by this server

This information should ideally be stored as a buffer-local variable
or maybe in some other fashion and then we should use this information
to make better "uniquifications" of nicknames.

-- 
Deniz Dogan