From cf07846a488fe1c5808ff2ecfdb228126821b2ea Mon Sep 17 00:00:00 2001 From: Nathan Osman Date: Fri, 25 May 2012 14:55:44 -0700 Subject: [PATCH] Modified feed parser and html5lib to allow data- HTML5 attributes through because they have no meaning to a browser or SGML parser and may contain meta-data or other attributes that scripts added to the planet page may require. --- planet/vendor/feedparser.py | 2 ++ planet/vendor/html5lib/sanitizer.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/planet/vendor/feedparser.py b/planet/vendor/feedparser.py index 76167ced..b4f373d6 100755 --- a/planet/vendor/feedparser.py +++ b/planet/vendor/feedparser.py @@ -2518,6 +2518,8 @@ def unknown_starttag(self, tag, attrs): elif key=='style': clean_value = self.sanitize_style(value) if clean_value: clean_attrs.append((key,clean_value)) + elif key.startswith('data-'): + clean_attrs.append((key, value)) _BaseHTMLProcessor.unknown_starttag(self, tag, clean_attrs) def unknown_endtag(self, tag): diff --git a/planet/vendor/html5lib/sanitizer.py b/planet/vendor/html5lib/sanitizer.py index 05face97..b507ea66 100644 --- a/planet/vendor/html5lib/sanitizer.py +++ b/planet/vendor/html5lib/sanitizer.py @@ -169,7 +169,7 @@ def sanitize_token(self, token): if token.has_key("data"): attrs = dict([(name,val) for name,val in token["data"][::-1] - if name in self.allowed_attributes]) + if name in self.allowed_attributes or name.startswith('data-')]) for attr in self.attr_val_is_uri: if not attrs.has_key(attr): continue