mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-11 20:49:33 +01:00
relay: fix channel not found errors on LINK when remote casemapping differs
This can happen, e.g. if the remote network uses casemapping=ascii and has a channel containing "|", and the local network uses casemapping=rfc1459. Thanks to iTzNavic for reporting.
This commit is contained in:
parent
537c643ed0
commit
4500e27931
@ -2450,8 +2450,12 @@ def link(irc, source, args):
|
||||
|
||||
args = link_parser.parse_args(args)
|
||||
|
||||
# Normalize channel case
|
||||
channel = irc.to_lower(str(args.channel))
|
||||
# Normalize channel case. For the target channel it's possible for the local and remote casemappings
|
||||
# to differ - if we find the unnormalized channel name in the list, we should just use that.
|
||||
# This mainly affects channels with e.g. | in them.
|
||||
channel_orig = str(args.channel)
|
||||
channel_norm = irc.to_lower(channel_orig)
|
||||
|
||||
localchan = irc.to_lower(str(args.localchannel or args.channel))
|
||||
remotenet = args.remotenet
|
||||
|
||||
@ -2495,12 +2499,15 @@ def link(irc, source, args):
|
||||
irc.error('Channel %r is already part of a relay.' % localchan)
|
||||
return
|
||||
|
||||
try:
|
||||
entry = db[(remotenet, channel)]
|
||||
except KeyError:
|
||||
if (remotenet, channel_orig) in db:
|
||||
channel = channel_orig
|
||||
elif (remotenet, channel_norm) in db:
|
||||
channel = channel_norm
|
||||
else:
|
||||
irc.error('No such relay %r exists.' % args.channel)
|
||||
return
|
||||
else:
|
||||
entry = db[(remotenet, channel)]
|
||||
|
||||
whitelist_mode = entry.get('use_whitelist', False)
|
||||
if ((not whitelist_mode) and irc.name in entry['blocked_nets']) or \
|
||||
(whitelist_mode and irc.name not in entry.get('allowed_nets', set())):
|
||||
|
Loading…
Reference in New Issue
Block a user