Restricting evaluated code variable names to Python valid characters ([_0-9a-zA-Z])

This commit is contained in:
Miroslav Stampar 2015-02-24 15:05:44 +01:00
parent e35c7fbb7a
commit 6bcc95a20d

View File

@ -848,7 +848,7 @@ class Connect(object):
for part in item.split(delimiter): for part in item.split(delimiter):
if '=' in part: if '=' in part:
name, value = part.split('=', 1) name, value = part.split('=', 1)
name = name.strip() name = re.sub(r"[^\w]", "", name.strip())
if name in keywords: if name in keywords:
name = "%s%s" % (name, EVALCODE_KEYWORD_SUFFIX) name = "%s%s" % (name, EVALCODE_KEYWORD_SUFFIX)
value = urldecode(value, convall=True, plusspace=(item==post and kb.postSpaceToPlus)) value = urldecode(value, convall=True, plusspace=(item==post and kb.postSpaceToPlus))
@ -858,7 +858,7 @@ class Connect(object):
for part in cookie.split(conf.cookieDel or DEFAULT_COOKIE_DELIMITER): for part in cookie.split(conf.cookieDel or DEFAULT_COOKIE_DELIMITER):
if '=' in part: if '=' in part:
name, value = part.split('=', 1) name, value = part.split('=', 1)
name = name.strip() name = re.sub(r"[^\w]", "", name.strip())
if name in keywords: if name in keywords:
name = "%s%s" % (name, EVALCODE_KEYWORD_SUFFIX) name = "%s%s" % (name, EVALCODE_KEYWORD_SUFFIX)
value = urldecode(value, convall=True) value = urldecode(value, convall=True)