Skip to content
Snippets Groups Projects
Unverified Commit 3c076c79 authored by Erik Johnston's avatar Erik Johnston Committed by GitHub
Browse files

Merge pull request #5808 from matrix-org/erikj/parse_decode_error

Handle incorrectly encoded query params correctly
parents 55a0c98d da378af4
No related branches found
No related tags found
No related merge requests found
Handle incorrectly encoded query params correctly by returning a 400.
...@@ -166,7 +166,12 @@ def parse_string_from_args( ...@@ -166,7 +166,12 @@ def parse_string_from_args(
value = args[name][0] value = args[name][0]
if encoding: if encoding:
value = value.decode(encoding) try:
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]" % (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment