From 40bad749563504f8c4c5d51ce5d78db7abce0df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20D=C4=85bek?= Date: Mon, 31 Jul 2017 15:38:33 +0200 Subject: [PATCH] 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 --- image/bin/my_init | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/image/bin/my_init b/image/bin/my_init index a6ded83..05c0b6a 100755 --- a/image/bin/my_init +++ b/image/bin/my_init @@ -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)