sanitize_shenvname returns string with [0-9a-zA-Z_] characters (#423)

* sanitize_shenvname returns string with [0-9a-zA-Z_] characters

* moved regex pattern to constant
This commit is contained in:
Przemysław Dąbek
2017-07-31 15:38:33 +02:00
committed by Zsolt Ero
parent b57f08c71f
commit 40bad74956

View File

@@ -20,7 +20,7 @@ LOG_LEVEL_WARN = 1
LOG_LEVEL_INFO = 2
LOG_LEVEL_DEBUG = 3
SHENV_NAME_WHITELIST_REGEX = re.compile('[^\w\-_\.]')
SHENV_NAME_WHITELIST_REGEX = re.compile('\W')
log_level = None
@@ -130,6 +130,7 @@ def shquote(s):
def sanitize_shenvname(s):
"""Return string with [0-9a-zA-Z_] characters"""
return re.sub(SHENV_NAME_WHITELIST_REGEX, "_", s)