From 7529bb5678107acaf59395cf37b270a08ba5214f Mon Sep 17 00:00:00 2001 From: Jonathan Wright Date: Wed, 26 Aug 2020 19:36:35 -0500 Subject: [PATCH 1/3] Force utf-8 for application/rdap+json per RFC 7483 --- aiohttp/client_reqrep.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index 33b3174a3cb..4742afc9974 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -948,8 +948,9 @@ def get_encoding(self) -> str: except LookupError: encoding = None if not encoding: - if mimetype.type == 'application' and mimetype.subtype == 'json': + if mimetype.type == 'application' and (mimetype.subtype == 'json' or mimetype.subtype == 'rdap'): # RFC 7159 states that the default encoding is UTF-8. + # RFC 7483 defines application/rdap+json encoding = 'utf-8' elif self._body is None: raise RuntimeError('Cannot guess the encoding of ' From 42835bd7cd278fcd168d457105075c4b227738ed Mon Sep 17 00:00:00 2001 From: Jonathan Wright Date: Wed, 26 Aug 2020 19:37:16 -0500 Subject: [PATCH 2/3] Update CONTRIBUTORS.txt --- CONTRIBUTORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index b40c107f6cd..1bb851d0a63 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -145,6 +145,7 @@ Jinkyu Yi Joel Watts Jon Nabozny Jonas Obrist +Jonathan Wright Jonny Tan Joongi Kim Josep Cugat From d61cb45f1455a4fa812663d490ad051326dfda3c Mon Sep 17 00:00:00 2001 From: Jonathan Wright Date: Wed, 26 Aug 2020 19:55:57 -0500 Subject: [PATCH 3/3] Create 4938.bugfix --- CHANGES/4938.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGES/4938.bugfix diff --git a/CHANGES/4938.bugfix b/CHANGES/4938.bugfix new file mode 100644 index 00000000000..3ad6904207b --- /dev/null +++ b/CHANGES/4938.bugfix @@ -0,0 +1 @@ +Add forced UTF-8 encoding for `application/rdap+json` responses.