mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 12:12:54 +01:00
Fix for escaping ValueError from ircdb.checkCapability.
This commit is contained in:
parent
046be171eb
commit
3d990599fe
37
src/ircdb.py
37
src/ircdb.py
@ -550,20 +550,7 @@ def _x(capability, ret):
|
|||||||
else:
|
else:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def checkCapability(hostmask, capability, users=users, channels=channels):
|
def _checkCapabilityForUnknownUser(capability, users=users, channels=channels):
|
||||||
"""Checks that the user specified by name/hostmask has the capabilty given.
|
|
||||||
"""
|
|
||||||
#debug.printf('*** checking %s for %s' % (hostmask, capability))
|
|
||||||
if world.startup:
|
|
||||||
#debug.printf('world.startup is active.')
|
|
||||||
return _x(capability, True)
|
|
||||||
try:
|
|
||||||
u = users.getUser(hostmask)
|
|
||||||
if u.secure and not u.checkHostmask(hostmask, useAuth=False):
|
|
||||||
debug.printf('Secure user with non-matching hostmask.')
|
|
||||||
raise KeyError
|
|
||||||
except KeyError:
|
|
||||||
#debug.printf('user could not be found.')
|
|
||||||
if isChannelCapability(capability):
|
if isChannelCapability(capability):
|
||||||
#debug.printf('isChannelCapability true.')
|
#debug.printf('isChannelCapability true.')
|
||||||
(channel, capability) = fromChannelCapability(capability)
|
(channel, capability) = fromChannelCapability(capability)
|
||||||
@ -587,6 +574,28 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
|
|||||||
else:
|
else:
|
||||||
#debug.printf('returning appropriate value given no good reason')
|
#debug.printf('returning appropriate value given no good reason')
|
||||||
return _x(capability, conf.defaultAllow)
|
return _x(capability, conf.defaultAllow)
|
||||||
|
|
||||||
|
def checkCapability(hostmask, capability, users=users, channels=channels):
|
||||||
|
"""Checks that the user specified by name/hostmask has the capabilty given.
|
||||||
|
"""
|
||||||
|
#debug.printf('*** checking %s for %s' % (hostmask, capability))
|
||||||
|
if world.startup:
|
||||||
|
#debug.printf('world.startup is active.')
|
||||||
|
return _x(capability, True)
|
||||||
|
try:
|
||||||
|
u = users.getUser(hostmask)
|
||||||
|
if u.secure and not u.checkHostmask(hostmask, useAuth=False):
|
||||||
|
debug.printf('Secure user with non-matching hostmask.')
|
||||||
|
raise KeyError
|
||||||
|
except KeyError:
|
||||||
|
# Raised when no hostmasks match.
|
||||||
|
return _checkCapabilityForUnknownUser(capability, users=users,
|
||||||
|
channels=channels)
|
||||||
|
except ValueError, e:
|
||||||
|
# Raised when multiple hostmasks match.
|
||||||
|
debug.msg('%s: %s' % (hostmask, e))
|
||||||
|
return _checkCapabilityForUnknownUser(capability, users=users,
|
||||||
|
channels=channels)
|
||||||
#debug.printf('user found.')
|
#debug.printf('user found.')
|
||||||
if capability in u.capabilities:
|
if capability in u.capabilities:
|
||||||
#debug.printf('found capability in u.capabilities.')
|
#debug.printf('found capability in u.capabilities.')
|
||||||
|
Loading…
Reference in New Issue
Block a user