mirror of
https://mau.dev/maunium/synapse.git
synced 2025-01-22 07:20:15 +01:00
Merge pull request #5808 from matrix-org/erikj/parse_decode_error
Handle incorrectly encoded query params correctly
This commit is contained in:
commit
3c076c79c5
2 changed files with 7 additions and 1 deletions
1
changelog.d/5808.misc
Normal file
1
changelog.d/5808.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Handle incorrectly encoded query params correctly by returning a 400.
|
|
@ -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…
Add table
Reference in a new issue