From 08aa72de82afe82c1c333b830388451b3bcc02d8 Mon Sep 17 00:00:00 2001 From: jesopo Date: Wed, 12 Sep 2018 10:18:12 +0100 Subject: [PATCH] Support 'strict-rfc1459' case mapping --- Utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Utils.py b/Utils.py index 97e15b59..12e9223b 100644 --- a/Utils.py +++ b/Utils.py @@ -8,6 +8,8 @@ REGEX_HTTP = re.compile("https?://", re.I) RFC1459_UPPER = r'\[]~' RFC1459_LOWER = r'|{}^' +STRICT_RFC1459_UPPER = r'\[]' +STRICT_RFC1459_LOWER = r'|{}' def remove_colon(s): if s.startswith(":"): @@ -21,11 +23,17 @@ def _rfc1459_lower(s): for upper, lower in zip(RFC1459_UPPER, RFC1459_LOWER): s = s.replace(upper, lower) return s.lower() +def _strict_rfc1459_lower(s): + for upper, lower in zip(STRICT_RFC1459_UPPER, STRICT_RFC1459_LOWER): + s = s.replace(upper, lower) + return s.lower() def irc_lower(server, s): if server.case_mapping == "ascii": return s.lower() elif server.case_mapping == "rfc1459": return _rfc1459_lower(s) + elif server.case_mapping == "strict-rfc1459": + return _strict_rfc1459_lower(s) else: raise ValueError("unknown casemapping '%s'" % server.case_mapping)