From ec5f5b865fb881e224ce813ab7372f271a2a44d6 Mon Sep 17 00:00:00 2001 From: pictuga Date: Fri, 21 Nov 2014 22:01:03 +0100 Subject: [PATCH] Make it easy to restrict available options --- morss/morss.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/morss/morss.py b/morss/morss.py index 03cac7f..a82c622 100644 --- a/morss/morss.py +++ b/morss/morss.py @@ -56,6 +56,13 @@ if 'SCRIPT_NAME' in os.environ: cgitb.enable() +def filterOptions(options): + allowed = ['proxy', 'clip', 'keep', 'cache', 'force', 'silent', 'pro', 'debug'] + filtered = dict([(key,value) for (key,value) in options.items() if key in allowed]) + + return filtered + + class MorssException(Exception): pass @@ -661,7 +668,7 @@ def cgi_app(environ, start_response): options = [] # init - options = Options(parseOptions(options)) + options = Options(filterOptions(parseOptions(options))) headers = {} global DEBUG @@ -758,7 +765,7 @@ def cgi_wrapper(environ, start_response): def cli_app(): - options = Options(parseOptions(sys.argv[1:-1])) + options = Options(filterOptions(parseOptions(sys.argv[1:-1]))) url = sys.argv[-1] global DEBUG