mirror of
https://github.com/pallets-eco/flask-debugtoolbar.git
synced 2026-01-03 04:00:03 -06:00
Fix case-insensitive HTML insertion
Keeps the case-insensitive search for "</body>" and removes extra scan for the tag by trying to insert the toolbar, and warning if unsuccessful.
This commit is contained in:
@@ -170,16 +170,16 @@ class DebugToolbarExtension(object):
|
||||
if response.is_sequence:
|
||||
response_html = response.data.decode(response.charset)
|
||||
|
||||
if "</body>" in response_html:
|
||||
toolbar_html = self.debug_toolbars[real_request].render_toolbar()
|
||||
toolbar_html = self.debug_toolbars[real_request].render_toolbar()
|
||||
|
||||
content = replace_insensitive(
|
||||
response_html, '</body>', toolbar_html + '</body>')
|
||||
content = replace_insensitive(
|
||||
response_html, '</body>', toolbar_html + '</body>')
|
||||
if content is response_html:
|
||||
warnings.warn('Could not insert debug toolbar. </body> tag not found in response.')
|
||||
else:
|
||||
content = content.encode(response.charset)
|
||||
response.response = [content]
|
||||
response.content_length = len(content)
|
||||
else:
|
||||
warnings.warn("Could not insert debug toolbar. <body> element not found in response.")
|
||||
|
||||
return response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user