From 2d60ea6c8dfc6cdc904bc01951f6fca3abfad9fc Mon Sep 17 00:00:00 2001 From: Matt Good Date: Thu, 16 Apr 2015 14:47:46 -0700 Subject: [PATCH] Fix case-insensitive HTML insertion Keeps the case-insensitive search for "" and removes extra scan for the tag by trying to insert the toolbar, and warning if unsuccessful. --- flask_debugtoolbar/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flask_debugtoolbar/__init__.py b/flask_debugtoolbar/__init__.py index 17aa860..84fd421 100644 --- a/flask_debugtoolbar/__init__.py +++ b/flask_debugtoolbar/__init__.py @@ -170,16 +170,16 @@ class DebugToolbarExtension(object): if response.is_sequence: response_html = response.data.decode(response.charset) - if "" 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, '', toolbar_html + '') + content = replace_insensitive( + response_html, '', toolbar_html + '') + if content is response_html: + warnings.warn('Could not insert debug toolbar. 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. element not found in response.") return response