aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-05-07 16:23:08 +0100
committerGravatar Sadie Powell2023-05-07 16:23:08 +0100
commit1d1abb11c35f45d69a4b07fb066d6ac3c00a2c46 (patch)
tree5fc0be22edb38578d51f0e7207c56d040e707630 /src
parentAllow customising who can receive the joinflood close notification. (diff)
Tighten up the rules for nicknames to match the Modern IRC spec.
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_codepage.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp
index 26c9b82bb..001f1d6da 100644
--- a/src/modules/m_codepage.cpp
+++ b/src/modules/m_codepage.cpp
@@ -59,17 +59,42 @@ public:
if (character >= '0' && character <= '9')
return AllowCharacterResult::NOT_VALID_AT_FRONT;
- // Nicknames can not begin with a : as it has special meaning within
- // the IRC message format.
- if (character == ':')
+ // Nicknames can not begin with a : or a $ as they have a special
+ // meaning within the IRC message format.
+ if (character == '$' || character == ':')
+ return AllowCharacterResult::NOT_VALID_AT_FRONT;
+
+ // Nicknames can not begin with a channel prefix character (e.g. #)
+ // as they are used to differentiate users from channels in message
+ // targets.
+ if (ServerInstance->Channels.IsPrefix(character))
+ return AllowCharacterResult::NOT_VALID_AT_FRONT;
+
+ // Nicknames can not begin with a prefix mode character (e.g. @)
+ // as they are used as a nick prefix when sending a STATUSMSG.
+ if (ServerInstance->Modes.FindPrefix(character))
return AllowCharacterResult::NOT_VALID_AT_FRONT;
}
- // Nicknames can never contain NUL, CR, LF, or SPACE as they are either
- // banned within an IRC message or have special meaning within the IRC
- // message format.
- if (!character || character == '\n' || character == '\r' || character == ' ')
- return AllowCharacterResult::NOT_VALID;
+ // Nicknames can never contain NUL, CR, LF, SPACE, COMMA, PERIOD,
+ // ASTERISK, QUESTION MARK, EXCLAMATION MARK, or AT SIGN as they are
+ // either banned within an IRC message or have special meaning within
+ // the IRC message format.
+ switch (character)
+ {
+ case '\0':
+ case '\n':
+ case '\r':
+ case ' ':
+ case '!':
+ case '*':
+ case ',':
+ case '.':
+ case '?':
+ case '@':
+ return AllowCharacterResult::NOT_VALID;
+ }
+
// The character is probably okay?
return AllowCharacterResult::OKAY;