From 76b5a42428f7d1453af84cbf09ec00c3c1a2f4fc Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Mon, 26 Oct 2020 00:06:56 +0100 Subject: [PATCH] supybot.defaultIgnore shouldn't ignore registered users. Even if they are not trusted. This fixes a regression in 97016b9c55e144ce234fdf67880b57dffc12aac3. This happens because 'user._checkCapability' raises a KeyError when the user has neither this cap or the anticap; which was mistakenly caught here by the 'except KeyError' expecting to catch non-existing users. (And that why 'try' blocks should be limited to as few lines as possible.) --- src/ircdb.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ircdb.py b/src/ircdb.py index bdef12ceb..2e01107e5 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -1172,18 +1172,25 @@ def checkIgnored(hostmask, recipient='', users=users, channels=channels): try: id = users.getUserId(hostmask) user = users.getUser(id) - if user._checkCapability('trusted'): - # Trusted users (including owners) shouldn't ever be ignored. - return False - elif user.ignore: - log.debug('Ignoring %s due to their IrcUser ignore flag.', hostmask) - return True except KeyError: # If there's no user... if conf.supybot.defaultIgnore(): log.debug('Ignoring %s due to conf.supybot.defaultIgnore', hostmask) return True + else: + try: + is_trusted = user._checkCapability('trusted') + except KeyError: + # neither explicitly trusted or -trusted -> consider them not + # trusted + is_trusted = False + if is_trusted: + # Trusted users (including owners) shouldn't ever be ignored. + return False + elif user.ignore: + log.debug('Ignoring %s due to their IrcUser ignore flag.', hostmask) + return True if ignores.checkIgnored(hostmask): log.debug('Ignoring %s due to ignore database.', hostmask) return True