From 206b21edc9e9eb6f185e5c3778e160f6f563a393 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Fri, 6 Aug 2010 07:02:39 -0400 Subject: [PATCH] Don't sanitize away unnamespaced HTML5 svg; convert to polyglot syntax instead. --- planet/vendor/feedparser.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/planet/vendor/feedparser.py b/planet/vendor/feedparser.py index 8e18838..76167ce 100755 --- a/planet/vendor/feedparser.py +++ b/planet/vendor/feedparser.py @@ -11,7 +11,7 @@ Recommended: CJKCodecs and iconv_codec """ -__version__ = "4.2-pre-" + "$Revision: 308 $"[11:14] + "-svn" +__version__ = "4.2-pre-" + "$Revision: 314 $"[11:14] + "-svn" __license__ = """Copyright (c) 2002-2008, Mark Pilgrim, All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -2467,6 +2467,15 @@ def unknown_starttag(self, tag, attrs): if tag in self.unacceptable_elements_with_end_tag: self.unacceptablestack += 1 + # add implicit namespaces to html5 inline svg/mathml + if self.type.endswith('html'): + if tag=='svg': + if not dict(attrs).get('xmlns'): + attrs.append( ('xmlns','http://www.w3.org/2000/svg') ) + if tag=='math': + if not dict(attrs).get('xmlns'): + attrs.append( ('xmlns','http://www.w3.org/1998/Math/MathML') ) + # not otherwise acceptable, perhaps it is MathML or SVG? if tag=='math' and ('xmlns','http://www.w3.org/1998/Math/MathML') in attrs: self.mathmlOK += 1