def test_scrubTrustsH1(self): """ Test that L{xquotient.scrubber.Scrubber} considers h1 to be a safe tag. Added because of #1895. """ node = parseString("<h1>Foo</h1>").documentElement scrubbed = scrub(node) h1s = getElementsByTagName(scrubbed, 'h1') self.assertEquals(len(h1s), 1) self.assertEquals(gatherTextNodes(h1s[0]).strip(), "Foo")
def test_scrubWithCIDLinkArg(self): """ Test that L{xquotient.scrubber.Scrubber.scrub} pays attention to the C{filterCIDLinks} argument, when passed <a>s """ node = parseString(""" <html> <a href="x" /> <a href="cid:foo" /> </html> """).documentElement scrubbed = scrub(node, filterCIDLinks=False) self.assertEquals( list(e.attributes['href'] for e in scrubbed.firstChild().childNodes), ['x', 'cid:foo']) scrubbed = scrub(node, filterCIDLinks=True) self.assertEquals( list(e.attributes['href'] for e in scrubbed.firstChild().childNodes), ['x'])
def test_scrubTrustsSpan(self): """ Test that L{xquotient.scrubber.Scrubber} considers span to be a safe tag. Added because of #1641. """ node = parseString(""" <html> <span style='font-weight: bold; font-family:"Book Antiqua"'> Hello </span> </html> """).documentElement scrubbed = scrub(node) spans = getElementsByTagName(scrubbed, 'span') self.assertEquals(len(spans), 1) self.assertEquals(gatherTextNodes(spans[0]).strip(), "Hello")