forked from Docker/baseimage-docker
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:
committed by
Zsolt Ero
parent
b57f08c71f
commit
40bad74956
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user