diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2017-10-14 18:26:58 +0100 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2017-10-14 18:26:58 +0100 |
commit | 256119a574fe37ba38a7aad0fd9952c9069ccfbf (patch) | |
tree | 294e564cbc7c69f1df5e0ad7a911afe03cc93d8d /poezio/xhtml.py | |
parent | 8af1a39d7eb95a18a2feddc53badb458798cc0de (diff) | |
download | poezio-256119a574fe37ba38a7aad0fd9952c9069ccfbf.tar.gz poezio-256119a574fe37ba38a7aad0fd9952c9069ccfbf.tar.bz2 poezio-256119a574fe37ba38a7aad0fd9952c9069ccfbf.tar.xz poezio-256119a574fe37ba38a7aad0fd9952c9069ccfbf.zip |
Add an option to disable CSS parsing.
Fixes #3340.
Diffstat (limited to 'poezio/xhtml.py')
-rw-r--r-- | poezio/xhtml.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/poezio/xhtml.py b/poezio/xhtml.py index f5b35b71..836c3868 100644 --- a/poezio/xhtml.py +++ b/poezio/xhtml.py @@ -17,13 +17,15 @@ import hashlib import re from base64 import b64encode, b64decode from os import path -from slixmpp.xmlstream import ET from urllib.parse import unquote from io import BytesIO from xml import sax from xml.sax import saxutils +from slixmpp.xmlstream import ET +from poezio.config import config + digits = '0123456789' # never trust the modules XHTML_NS = 'http://www.w3.org/1999/xhtml' @@ -311,6 +313,7 @@ class XHTMLHandler(sax.ContentHandler): self.tmp_dir = tmp_dir self.extract_images = extract_images + self.enable_css_parsing = config.get('enable_css_parsing') @property def result(self): @@ -336,7 +339,7 @@ class XHTMLHandler(sax.ContentHandler): attrs = {name: value for ((ns, name), value) in attrs.items() if ns is None} self.attrs.append(attrs) - if 'style' in attrs: + if 'style' in attrs and self.enable_css_parsing: style = _parse_css(attrs['style']) self.append_formatting(style) @@ -420,7 +423,7 @@ class XHTMLHandler(sax.ContentHandler): builder.append('\n') self.is_pre = False - if 'style' in attrs: + if 'style' in attrs and self.enable_css_parsing: self.pop_formatting() if 'title' in attrs: |