mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-24 19:24:13 +01:00
relay: check for nicks starting with numbers or - after removing Unicode
This commit is contained in:
parent
1780271dd0
commit
c9176a06fc
@ -191,12 +191,24 @@ def normalize_nick(irc, netname, nick, times_tagged=0, uid=''):
|
||||
separator = separator.replace('/', FALLBACK_SEPARATOR)
|
||||
nick = nick.replace('/', FALLBACK_SEPARATOR)
|
||||
|
||||
if nick.startswith(tuple(string.digits+'-')):
|
||||
# Loop over every character in the nick, making sure that it only contains valid
|
||||
# characters.
|
||||
if not is_unicode_capable:
|
||||
nick = _sanitize(nick)
|
||||
else:
|
||||
# UnrealIRCd 4's forbidden nick chars, from
|
||||
# https://github.com/unrealircd/unrealircd/blob/02d69e7d8/src/modules/charsys.c#L152-L163
|
||||
for char in """!+%@&~#$:'\"?*,.""":
|
||||
nick = nick.replace(char, FALLBACK_CHARACTER)
|
||||
|
||||
if nick.startswith(tuple(string.digits)):
|
||||
# On TS6 IRCds, nicks that start with 0-9 are only allowed if
|
||||
# they match the UID of the originating server. Otherwise, you'll
|
||||
# get nasty protocol violation SQUITs!
|
||||
# Nicks starting with - are likewise not valid.
|
||||
nick = '_' + nick
|
||||
elif nick.startswith('-'):
|
||||
# Nicks starting with - are likewise not valid.
|
||||
nick = '_' + nick[1:]
|
||||
|
||||
# Maximum allowed length that relay nicks may have, minus the /network tag if used.
|
||||
allowedlength = maxnicklen
|
||||
@ -214,16 +226,6 @@ def normalize_nick(irc, netname, nick, times_tagged=0, uid=''):
|
||||
if times_tagged >= 1:
|
||||
nick += suffix
|
||||
|
||||
# Loop over every character in the nick, making sure that it only contains valid
|
||||
# characters.
|
||||
if not is_unicode_capable:
|
||||
nick = _sanitize(nick)
|
||||
else:
|
||||
# UnrealIRCd 4's forbidden nick chars, from
|
||||
# https://github.com/unrealircd/unrealircd/blob/02d69e7d8/src/modules/charsys.c#L152-L163
|
||||
for char in """!+%@&~#$:'\"?*,.""":
|
||||
nick = nick.replace(char, FALLBACK_CHARACTER)
|
||||
|
||||
while irc.nick_to_uid(nick) not in (None, uid):
|
||||
# The nick we want exists: Increase the separator length by 1 if the user was already
|
||||
# tagged, but couldn't be created due to a nick conflict. This can happen when someone
|
||||
|
Loading…
Reference in New Issue
Block a user