mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-04-26 17:57:54 +02:00
Network: Properly parse WHOIS response
The 319 message that indicates which channel(s) a user is in prefix the channel name with the modes (@, +, !, etc.) applied to that user. These need to be stripped from the channel name before we feed it to irc.state.channels.get(), otherwise when irc.state.channels.get() returns None we assume the channel can't be private and leak information.
This commit is contained in:
parent
0806c0bbc3
commit
408ab6f88a
@ -1,5 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||||
|
# Copyright (c) 2010, James Vega
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -166,7 +167,19 @@ class Network(callbacks.Plugin):
|
|||||||
normal = []
|
normal = []
|
||||||
halfops = []
|
halfops = []
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
|
origchan = channel
|
||||||
|
channel = channel.lstrip('@%+~!')
|
||||||
|
# UnrealIRCd uses & for user modes and disallows it as a
|
||||||
|
# channel-prefix, flying in the face of the RFC. Have to
|
||||||
|
# handle this specially when processing WHOIS response.
|
||||||
|
testchan = channel.lstrip('&')
|
||||||
|
if testchan != channel and irc.isChannel(testchan):
|
||||||
|
channel = testchan
|
||||||
|
diff = len(channel) - len(origchan)
|
||||||
|
modes = origchan[:diff]
|
||||||
chan = irc.state.channels.get(channel)
|
chan = irc.state.channels.get(channel)
|
||||||
|
# The user is in a channel the bot is in, so the ircd may have
|
||||||
|
# responded with otherwise private data.
|
||||||
if chan:
|
if chan:
|
||||||
# Skip channels the callee isn't in. This helps prevents
|
# Skip channels the callee isn't in. This helps prevents
|
||||||
# us leaking information when the channel is +s or the
|
# us leaking information when the channel is +s or the
|
||||||
@ -178,14 +191,14 @@ class Network(callbacks.Plugin):
|
|||||||
if 's' in chan.modes and \
|
if 's' in chan.modes and \
|
||||||
not ircutils.strEqual(replyMsg.args[0], channel):
|
not ircutils.strEqual(replyMsg.args[0], channel):
|
||||||
continue
|
continue
|
||||||
if channel.startswith('@'):
|
if not modes:
|
||||||
ops.append(channel[1:])
|
|
||||||
elif channel.startswith('%'):
|
|
||||||
halfops.append(channel[1:])
|
|
||||||
elif channel.startswith('+'):
|
|
||||||
voices.append(channel[1:])
|
|
||||||
else:
|
|
||||||
normal.append(channel)
|
normal.append(channel)
|
||||||
|
elif utils.iter.any(lambda c: c in modes,('@', '&', '~', '!')):
|
||||||
|
ops.append(channel[1:])
|
||||||
|
elif utils.iter.any(lambda c: c in modes, ('%',)):
|
||||||
|
halfops.append(channel[1:])
|
||||||
|
elif utils.iter.any(lambda c: c in modes, ('+',)):
|
||||||
|
voices.append(channel[1:])
|
||||||
L = []
|
L = []
|
||||||
if ops:
|
if ops:
|
||||||
L.append(format('is an op on %L', ops))
|
L.append(format('is an op on %L', ops))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user