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

Handle incorrectly encoded query params correctly #5808

Merged
merged 2 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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