From 2d9215b05240f46576ae83df0aa069fec347348f Mon Sep 17 00:00:00 2001 From: j Date: Fri, 28 Sep 2018 16:33:44 +0200 Subject: [PATCH] strip script and style blocks --- content_plugins/shortcuts.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content_plugins/shortcuts.py b/content_plugins/shortcuts.py index 9abe93c..ce0b269 100644 --- a/content_plugins/shortcuts.py +++ b/content_plugins/shortcuts.py @@ -16,6 +16,8 @@ def render_page_as_html(page, template, context_data, css_selector=None): if css_selector: import lxml.html doc = lxml.html.fromstring(html) + for element in doc.cssselect('script,style'): + element.getparent().remove(element) html = [] for part in doc.cssselect(css_selector): html.append(lxml.html.tostring(part).decode().strip())