mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Made usernames case-insensitive.
This commit is contained in:
parent
df9ce1b632
commit
feb85382af
13
src/ircdb.py
13
src/ircdb.py
@ -376,15 +376,16 @@ class UsersDB(object):
|
||||
else:
|
||||
raise ValueError, 'Ids %r matched.' % ids
|
||||
else: # Not a hostmask, must be a name.
|
||||
s = s.lower()
|
||||
try:
|
||||
return self._nameCache[s]
|
||||
except KeyError:
|
||||
for (id, user) in enumerate(self.users):
|
||||
if user is None:
|
||||
continue
|
||||
if s == user.name:
|
||||
if s == user.name.lower():
|
||||
self._nameCache[s] = id
|
||||
self._nameCache.setdefault(id, sets.Set()).add(s)
|
||||
self._nameCache[id] = s
|
||||
return id
|
||||
else:
|
||||
raise KeyError, s
|
||||
@ -429,8 +430,7 @@ class UsersDB(object):
|
||||
except KeyError:
|
||||
continue
|
||||
if id in self._nameCache:
|
||||
for name in self._nameCache[id]:
|
||||
del self._nameCache[name]
|
||||
del self._nameCache[self._nameCache[id]]
|
||||
del self._nameCache[id]
|
||||
if id in self._hostmaskCache:
|
||||
for hostmask in self._hostmaskCache[id]:
|
||||
@ -444,8 +444,9 @@ class UsersDB(object):
|
||||
if not 0 <= id < len(self.users) or self.users[id] is None:
|
||||
raise KeyError, id
|
||||
self.users[id] = None
|
||||
for name in self._nameCache.get(id, []):
|
||||
del self._nameCache[name]
|
||||
if id in self._nameCache:
|
||||
del self._nameCache[self._nameCache[id]]
|
||||
del self._nameCache[id]
|
||||
for hostmask in self._hostmaskCache.get(id, []):
|
||||
del self._hostmaskCache[hostmask]
|
||||
|
||||
|
@ -275,6 +275,7 @@ class UsersDBTestCase(unittest.TestCase):
|
||||
u.name = 'foo'
|
||||
self.users.setUser(id, u)
|
||||
self.assertEqual(self.users.getUser('foo'), u)
|
||||
self.assertEqual(self.users.getUser('FOO'), u)
|
||||
self.assertEqual(self.users.getUser(hostmask), u)
|
||||
self.assertEqual(self.users.getUser(banmask), u)
|
||||
# The UsersDB shouldn't allow users to be added whose hostmasks
|
||||
|
Loading…
Reference in New Issue
Block a user