new option for checking path/user value

This commit is contained in:
Peter Bieringer
2026-04-21 18:51:58 +02:00
parent e279e4f803
commit af5121ab34
6 changed files with 66 additions and 1 deletions

View File

@@ -48,6 +48,8 @@ DEFAULT_CONFIG_PATH: str = os.pathsep.join([
PROFILING: Sequence[str] = ("per_request", "per_request_method", "none")
VALIDATE_TYPES: Sequence[str] = ("none", "minimal", "unicodeletter", "strict")
def positive_int(value: Any) -> int:
value = int(value)
@@ -84,6 +86,12 @@ def logging_level(value: Any) -> str:
return value
def validate_types(value: Any) -> str:
if value not in VALIDATE_TYPES:
raise ValueError("unsupported validation type: %r" % value)
return value
def profiling(value: Any) -> str:
if value not in PROFILING:
raise ValueError("unsupported profiling: %r" % value)
@@ -221,6 +229,14 @@ DEFAULT_CONFIG_SCHEMA: types.CONFIG_SCHEMA = OrderedDict([
"value": "",
"help": "script name to strip from URI if called by reverse proxy (default taken from HTTP_X_SCRIPT_NAME or SCRIPT_NAME)",
"type": str}),
("validate_user_value", {
"value": "minimal",
"help": "validate user value (" + "|".join(VALIDATE_TYPES) + ")",
"type": validate_types}),
("validate_path_value", {
"value": "minimal",
"help": "validate path value (" + "|".join(VALIDATE_TYPES) + ")",
"type": validate_types}),
("_internal_server", {
"value": "False",
"help": "the internal server is used",