mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
parse_modes: case fold parameters to modes
This commit is contained in:
parent
6ad34672d3
commit
da58669de5
14
classes.py
14
classes.py
@ -906,6 +906,13 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
|
|||||||
args = args[1:]
|
args = args[1:]
|
||||||
|
|
||||||
existing = set(existing)
|
existing = set(existing)
|
||||||
|
existing_casemap = {}
|
||||||
|
for modepair in existing:
|
||||||
|
arg = modepair[1]
|
||||||
|
if arg is not None:
|
||||||
|
existing_casemap[(modepair[0], self.to_lower(arg))] = modepair
|
||||||
|
else:
|
||||||
|
existing_casemap[modepair] = modepair
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
for mode in modestring:
|
for mode in modestring:
|
||||||
@ -947,10 +954,13 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
|
|||||||
|
|
||||||
log.debug('(%s) parse_modes: checking if +%s %s is in old modes list: %s', self.name, mode, arg, existing)
|
log.debug('(%s) parse_modes: checking if +%s %s is in old modes list: %s', self.name, mode, arg, existing)
|
||||||
|
|
||||||
if (mode, arg) not in existing:
|
arg = self.to_lower(arg)
|
||||||
# Ignore attempts to unset bans that don't exist.
|
casefolded_modepair = existing_casemap.get((mode, arg)) # Case fold arguments as needed
|
||||||
|
if casefolded_modepair not in existing:
|
||||||
|
# Ignore attempts to unset parameter modes that don't exist.
|
||||||
log.debug("(%s) parse_modes(): ignoring removal of non-existent list mode +%s %s", self.name, mode, arg)
|
log.debug("(%s) parse_modes(): ignoring removal of non-existent list mode +%s %s", self.name, mode, arg)
|
||||||
continue
|
continue
|
||||||
|
arg = casefolded_modepair[1]
|
||||||
|
|
||||||
elif prefix == '+' and mode in supported_modes['*C']:
|
elif prefix == '+' and mode in supported_modes['*C']:
|
||||||
# Only has parameter when setting.
|
# Only has parameter when setting.
|
||||||
|
@ -382,6 +382,13 @@ class BaseProtocolTest(unittest.TestCase):
|
|||||||
[('-b', '*!*@test1')],
|
[('-b', '*!*@test1')],
|
||||||
"First ban should have been removed (different case)"
|
"First ban should have been removed (different case)"
|
||||||
)
|
)
|
||||||
|
self.p.apply_modes('#testruns', [('+b', '*!*@Test2')])
|
||||||
|
self.assertEqual(
|
||||||
|
# remove second ban despite different case
|
||||||
|
self.p.parse_modes('#testruns', ['-b', '*!*@test2']),
|
||||||
|
[('-b', '*!*@Test2')],
|
||||||
|
"Second ban should have been removed (different case)"
|
||||||
|
)
|
||||||
|
|
||||||
def test_parse_modes_user_rfc(self):
|
def test_parse_modes_user_rfc(self):
|
||||||
u = self._make_user('testuser', uid='100')
|
u = self._make_user('testuser', uid='100')
|
||||||
|
Loading…
Reference in New Issue
Block a user