mirror of
https://github.com/aljazceru/CTFd.git
synced 2026-01-09 17:14:26 +01:00
Show length error when Configs provided are too long (#1920)
* Show an error when a config is too long
This commit is contained in:
@@ -89,6 +89,9 @@ class ConfigList(Resource):
|
||||
response = schema.load(req)
|
||||
|
||||
if response.errors:
|
||||
# Inject config key into error
|
||||
config_key = response.data["key"]
|
||||
response.errors["value"][0] = f"{config_key} config is too long"
|
||||
return {"success": False, "errors": response.errors}, 400
|
||||
|
||||
db.session.add(response.data)
|
||||
@@ -109,8 +112,15 @@ class ConfigList(Resource):
|
||||
)
|
||||
def patch(self):
|
||||
req = request.get_json()
|
||||
schema = ConfigSchema()
|
||||
|
||||
for key, value in req.items():
|
||||
response = schema.load({"key": key, "value": value})
|
||||
if response.errors:
|
||||
# Inject config key into error
|
||||
config_key = response.data["key"]
|
||||
response.errors["value"][0] = f"{config_key} config is too long"
|
||||
return {"success": False, "errors": response.errors}, 400
|
||||
set_config(key=key, value=value)
|
||||
|
||||
clear_config()
|
||||
|
||||
Reference in New Issue
Block a user