Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5808 from matrix-org/erikj/parse_decode_error
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Feb 20, 2020
2 parents e7ffd4a + 3c076c7 commit 6e7f378
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/5808.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle incorrectly encoded query params correctly by returning a 400.
7 changes: 6 additions & 1 deletion synapse/http/servlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,12 @@ def parse_string_from_args(
value = args[name][0]

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:
message = "Query parameter %r must be one of [%s]" % (
Expand Down

0 comments on commit 6e7f378

Please sign in to comment.