SVG tags and missing namespace prefixes breaks BeautifulSoup when using htm5lib..
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Beautiful Soup |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Stack error if prefix is None (which can happen with this SVG tag:
<svg xmlns="http://
diff --git a/bs4/element.py b/bs4/element.py
index 4a4d3ed..3058d5e 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -26,6 +26,8 @@ class NamespacedAttri
def __new__(cls, prefix, name, namespace=None):
if name is None:
obj = unicode.
+ elif prefix is None and name:
+ obj = unicode.
else:
obj = unicode.
obj.prefix = prefix
diff --git a/bs4/tests/
index f195f7d..b2a9f48 100644
--- a/bs4/tests/
+++ b/bs4/tests/
@@ -56,3 +56,8 @@ class HTML5LibBuilder
+
+ def test_prefixed_
+ soup = self.soup('<svg xmlns="http://
+ self.assertEqua
+ self.assertEqua
There is similar code in 4.1.2.