From 84fef789b584092841b8d161d4e788d994799c01 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Tue, 23 May 2023 09:20:21 +0200 Subject: [PATCH] Ignore decoding error when charset is erroneous --- nemubot/tools/web.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nemubot/tools/web.py b/nemubot/tools/web.py index ab20643..a545b19 100644 --- a/nemubot/tools/web.py +++ b/nemubot/tools/web.py @@ -191,9 +191,9 @@ def getURLContent(url, body=None, timeout=7, header=None, decode_error=False, import http.client if res.status == http.client.OK or res.status == http.client.SEE_OTHER: - return data.decode(charset).strip() + return data.decode(charset, errors='ignore').strip() elif decode_error: - return data.decode(charset).strip() + return data.decode(charset, errors='ignore').strip() else: raise IMException("A HTTP error occurs: %d - %s" % (res.status, http.client.responses[res.status]))