From 94bf1ab01ea138449763d9a089687ce9fcb4c7e7 Mon Sep 17 00:00:00 2001 From: Guido Serra Date: Fri, 30 Aug 2019 14:50:21 +0200 Subject: [PATCH] seems we made it properly maketrans() --- wicd/wnettools.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 3a21cd7..1424062 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -78,20 +78,23 @@ class BaseWirelessInterface() -- Control a wireless network interface. RALINK_DRIVER = 'ralink legacy' NONE_DRIVER = 'none' -blacklist_strict = '!"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ ' -blacklist_norm = ";`$!*|><&\\" +blacklist_strict = list('!"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ ') +blacklist_norm = list(";`$!*|><&\\") + +blacklist_strict_t = str.maketrans(dict.fromkeys(blacklist_strict, None)) +blacklist_norm_t = str.maketrans(dict.fromkeys(blacklist_norm, None)) def _sanitize_string(string): """ Sanitize string. """ if string: - return str(string).translate(blacklist_norm) + return str(string).translate(blacklist_norm_t) else: return string def _sanitize_string_strict(string): """ Sanitize string in a stricter way. """ if string: - return str(string).translate(blacklist_strict) + return str(string).translate(blacklist_strict_t) else: return string