Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
seems we made it properly maketrans()
Browse files Browse the repository at this point in the history
  • Loading branch information
zeph committed Aug 30, 2019
1 parent b92d5b0 commit 94bf1ab
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions wicd/wnettools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 94bf1ab

Please sign in to comment.