def test_scrubCIDLinks(self): """ Test L{xquotient.scrubber.Scrubber.scrubCIDLinks} with a bunch of different nodes """ node = parseString(""" <html> <img src="cid:foo" /> <a href="x" name="1" /> <iframe src="cid:bar" /> <iframe name="2" /> <a href="cid:xxx" /> <img src="123" name="3" /> <link href="cid:foo" /> <link href="xyz" name="4" /> <script src="cid:baz" /> <script href="x" name="5" /> </html>""").documentElement scrubCIDLinks(node) self.assertEquals( list(int(e.attributes['name']) for e in node.childNodes), [1, 2, 3, 4, 5])
def test_scrubCIDLinksWithLinks(self): """ Test L{xquotient.scrubber.Scrubber.scrubCIDLinks with <a>s """ node = parseString(""" <html> <a href="cid:foo">with a CID URI</a> <a href="not a cid uri">without a CID URI</a> </html> """).documentElement scrubCIDLinks(node) (link,) = node.childNodes self.assertEquals(link.attributes['href'], 'not a cid uri')
def test_scrubCIDLinksWithIFrames(self): """ Test L{xquotient.scrubber.Scrubber.scrubCIDLinks} with <iframe>s """ node = parseString(""" <html> <IFRAME SRC="CID:foo">with a CID URL</IFRAME> <IFRAME SRC="http://foo.bar">without a CID URI</IFRAME> </html> """).documentElement scrubCIDLinks(node) (iframe,) = node.childNodes self.assertEquals(iframe.attributes['src'], 'http://foo.bar')
def test_scrubCIDLinksWithLinks(self): """ Test L{xquotient.scrubber.Scrubber.scrubCIDLinks with <a>s """ node = parseString(""" <html> <a href="cid:foo">with a CID URI</a> <a href="not a cid uri">without a CID URI</a> </html> """).documentElement scrubCIDLinks(node) (link, ) = node.childNodes self.assertEquals(link.attributes['href'], 'not a cid uri')
def test_scrubCIDLinksWithIFrames(self): """ Test L{xquotient.scrubber.Scrubber.scrubCIDLinks} with <iframe>s """ node = parseString(""" <html> <IFRAME SRC="CID:foo">with a CID URL</IFRAME> <IFRAME SRC="http://foo.bar">without a CID URI</IFRAME> </html> """).documentElement scrubCIDLinks(node) (iframe, ) = node.childNodes self.assertEquals(iframe.attributes['src'], 'http://foo.bar')
def test_scrubCIDLinksWithImages(self): """ Test L{xquotient.scrubber.Scrubber.scrubCIDLinks} with <img>s """ node = parseString(""" <html> <img src="cid:foo" /> <img src="http://foo.bar" /> <img src="cid:bar" /> <img src="http://bar.baz" /> </html> """).documentElement scrubCIDLinks(node) self.assertEquals(list(e.attributes['src'] for e in node.childNodes), ['http://foo.bar', 'http://bar.baz'])