webconfig: Check variable name and value

Theoretically if this only includes simple characters, it won't cause
any issues. We already validate in other places but it doesn't hurt to
do this twice.
This commit is contained in:
Fabian Homborg 2021-12-13 21:59:08 +01:00
parent c954d70e2f
commit 06fada7445

View File

@ -1150,7 +1150,15 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
# This is needed for 'fish_pager_color' vars. # This is needed for 'fish_pager_color' vars.
if name.startswith("fish_"): if name.startswith("fish_"):
varname = name varname = name
# TODO: Check if the varname is allowable. # Check if the varname is allowable.
varname = varname.strip()
if not re.match("^[a-zA-Z0-9_]+$", varname):
print("Refusing to use variable name: '", varname, "'")
return
color = color.strip()
if not re.match("^[a-zA-Z0-9_= -]*$", color):
print("Refusing to use color value: ", color)
return
command = "set -U " + varname command = "set -U " + varname
command += " " + color command += " " + color