Permalink
Browse files

fixes #3, added regression test

  • Loading branch information...
1 parent 185d5a7 commit e5c5b96c6193dcaa0894dba41ec089e474d580c8 @jmoiron committed Mar 30, 2012
Showing with 13 additions and 3 deletions.
  1. +3 −3 speedparser/speedparser.py
  2. +10 −0 tests/regressions.py
@@ -85,12 +85,12 @@ def strip_outer_tag(text):
return stripped[stripped.index('>')+1:stripped.rindex('<')]
return text
-nsre = re.compile(r'xmlns=[\'"](.+?)[\'"]')
+nsre = re.compile(r'xmlns\s*=\s*[\'"](.+?)[\'"]')
def strip_namespace(document):
if document[:1000].count('xmlns') > 5:
- if 'xmlns=' not in document[:1000]:
+ if 'xmlns' not in document[:1000]:
return None, document
- elif 'xmlns=' not in document[:400]:
+ elif 'xmlns' not in document[:400]:
return None, document
match = nsre.search(document)
if match:
View
@@ -74,3 +74,13 @@ def test_rdf_rss_090_support(self):
feed = """<?xml version="1.0" encoding="utf-8"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://my.netscape.com/rdf/simple/0.9/"><channel><title>heise online News</title><link>http://www.heise.de/newsticker/</link><description>Nachrichten nicht nur aus der Welt der Computer</description></channel><item><title>Am 6. Juni ist World IPv6 Launch Day</title><link>http://www.heise.de/newsticker/meldung/Am-6-Juni-ist-World-IPv6-Launch-Day-1415071.html/from/rss09</link><description>Am 6. Juni 2012 veranstaltet die Internet Society den IPv6 World Launch Day, an dem teilnehmende Internet Service Provider, Netzwerkhersteller und Service-Anbieter dauerhaft IPv6 schalten werden.</description></item></rdf:RDF>"""
self.assertTrue(parse(feed).bozo == 0)
self.assertTrue(len(parse(feed).entries) == 1)
+
+class XmlnsSpaceSupport(TestCase):
+ def test_xmlns_space_support(self):
+ from os import path
+ import ipdb; ipdb.set_trace();
+ feed = open(path.join(path.dirname(__file__), "test-feeds/co.atom")).read()
+ res = parse(feed)
+ self.assertTrue(res.bozo == 0)
+ self.assertTrue(len(res.entries) == 3)
+

0 comments on commit e5c5b96

Please sign in to comment.