Handle incorrectly encoded query params correctly
parent
58af30a6c7
commit
d2e3d5b9db
|
@ -166,7 +166,12 @@ def parse_string_from_args(
|
||||||
value = args[name][0]
|
value = args[name][0]
|
||||||
|
|
||||||
if encoding:
|
if encoding:
|
||||||
|
try:
|
||||||
value = value.decode(encoding)
|
value = value.decode(encoding)
|
||||||
|
except ValueError:
|
||||||
|
raise SynapseError(
|
||||||
|
400, "Query parameter %r must be %s" % (name, encoding)
|
||||||
|
)
|
||||||
|
|
||||||
if allowed_values is not None and value not in allowed_values:
|
if allowed_values is not None and value not in allowed_values:
|
||||||
message = "Query parameter %r must be one of [%s]" % (
|
message = "Query parameter %r must be one of [%s]" % (
|
||||||
|
|
Loading…
Reference in New Issue