Skip to content

Commit

Permalink
Fix too lax expected JSON content-type parsing
Browse files Browse the repository at this point in the history
E.g. application/jsonfoobar is not expected for it, but ones with
parameters -- for example charset -- are. The IANA registered
application/json-seq is a good example.
  • Loading branch information
scop committed Nov 1, 2021
1 parent 203e3cf commit 4a4dc9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/6180.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix JSON media type matching to not accept everything starting with application/json.
4 changes: 3 additions & 1 deletion aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def iscoroutinefunction(func: Any) -> bool:
return asyncio.iscoroutinefunction(func)


json_re = re.compile(r"(?:application/|[\w.-]+/[\w.+-]+?\+)json", re.IGNORECASE)
json_re = re.compile(
r"(?:application/|[\w.-]+/[\w.+-]+?\+)json(?:\s*;.*)?$", re.IGNORECASE
)


class BasicAuth(namedtuple("BasicAuth", ["login", "password", "encoding"])):
Expand Down

0 comments on commit 4a4dc9f

Please sign in to comment.