From 9571d06df527344f7dd310f95017cf761600ec0b Mon Sep 17 00:00:00 2001 From: Hiromasa Ihara Date: Fri, 13 Oct 2023 22:35:25 +0900 Subject: [PATCH] fix: drop response.charset because charset deprecated (#206) I took a quick peek at upstream to see if this has any backwards-breaking issues whereby we'd need to check the `werkzeug` version, but from my reading it looks it should be fine most of the time. Also, this was deprecated back in April's `2.3.0` release and then removed in the recent `3.0.0` release, so I suspect most of our userbase will have already migrated to those versions. Given this lib is a dev-tooling library not typically used in production, I'm not too worried about ensuring we support the 0.01% case where someone is using an old version of `werkzeug` + a custom charset. More context: * https://github.com/pallets/werkzeug/issues/2602 * https://github.com/pallets/werkzeug/pull/2641 * https://github.com/pallets/werkzeug/pull/2768 --- src/flask_debugtoolbar/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flask_debugtoolbar/__init__.py b/src/flask_debugtoolbar/__init__.py index 0e11dd0..f02994d 100644 --- a/src/flask_debugtoolbar/__init__.py +++ b/src/flask_debugtoolbar/__init__.py @@ -231,9 +231,9 @@ class DebugToolbarExtension(object): return response if 'gzip' in response.headers.get('Content-Encoding', ''): - response_html = gzip_decompress(response.data).decode(response.charset) + response_html = gzip_decompress(response.data).decode() else: - response_html = response.data.decode(response.charset) + response_html = response.get_data(as_text=True) no_case = response_html.lower() body_end = no_case.rfind('')