Check nicks on the IRC listener with the HTTP API's rule (closes #142) #152

Merged
clawbot merged 1 commits from issue-142-irc-nick-rule into next 2026-10-20 17:31:32 +02:00
Collaborator

Closes #142

The nick rule moves from internal/handlers to internal/service as ValidNick, next to validChannelRe. The HTTP API calls it for session creation and NICK, as before. The IRC listener now calls it too, for NICK before registration (handlePreRegistration) and after it (handleNick), in place of the 32-byte cut; maxNickLen is gone.

On the IRC listener a refused nick gets ERR_ERRONEUSNICKNAME (432) and changes nothing. Before registration the earlier nick stays and the refused NICK does not start registration. After registration the refused nick never reaches the service, so no NICK is broadcast.

TestNickRefused in internal/ircserver sends each case from the issue (spaces, empty, 33 characters, !, @, #) before and after registration. It checks that each 432 still names the earlier nick, that USER then registers with it, and that a second member of the channel sees no NICK and gets the sender's next message under its old nick.

Judgement call: the 432 reply echoes the refused nick, as RFC 2812 has it, so a refused nick with spaces splits that reply, which only its sender receives, into extra parameters.
Judgement call: the IRC listener does not trim spaces around a nick as the HTTP API does, so NICK :bob (trailing space) is refused.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/neoirc/issues/142 The nick rule moves from `internal/handlers` to `internal/service` as `ValidNick`, next to `validChannelRe`. The HTTP API calls it for session creation and `NICK`, as before. The IRC listener now calls it too, for `NICK` before registration (`handlePreRegistration`) and after it (`handleNick`), in place of the 32-byte cut; `maxNickLen` is gone. On the IRC listener a refused nick gets ERR_ERRONEUSNICKNAME (432) and changes nothing. Before registration the earlier nick stays and the refused `NICK` does not start registration. After registration the refused nick never reaches the service, so no `NICK` is broadcast. `TestNickRefused` in `internal/ircserver` sends each case from the issue (spaces, empty, 33 characters, `!`, `@`, `#`) before and after registration. It checks that each 432 still names the earlier nick, that `USER` then registers with it, and that a second member of the channel sees no `NICK` and gets the sender's next message under its old nick. Judgement call: the 432 reply echoes the refused nick, as RFC 2812 has it, so a refused nick with spaces splits that reply, which only its sender receives, into extra parameters. Judgement call: the IRC listener does not trim spaces around a nick as the HTTP API does, so `NICK :bob ` (trailing space) is refused. Model: opus-5-5
clawbot added the needs-review label 2026-10-20 17:10:50 +02:00
clawbot self-assigned this 2026-10-20 17:10:50 +02:00
clawbot added 1 commit 2026-10-20 17:10:50 +02:00
The nick rule moves from internal/handlers to internal/service as
ValidNick, and the HTTP API and both IRC listener NICK paths call it.
The IRC listener used to cut a nick to 32 bytes and accept anything
else, so a nick with spaces such as "bob PRIVMSG #inj :hi" made the
lines built from it read as another user's PRIVMSG. It now answers a
nick the rule refuses with ERR_ERRONEUSNICKNAME (432), before and
after registration, and keeps the nick as it was.

Model: opus-5-5
Author
Collaborator

PASS

Model: opus-5-5

**PASS** Model: opus-5-5
clawbot removed the needs-review label 2026-10-20 17:27:14 +02:00
clawbot merged commit 0b09cf838c into next 2026-10-20 17:31:32 +02:00
clawbot deleted branch issue-142-irc-nick-rule 2026-10-20 17:31:33 +02:00
Sign in to join this conversation.