mirror of https://github.com/scrapy/scrapy.git
Added test against XXE attacks for Sitemap
This commit is contained in:
parent
c2a424daae
commit
d034df36e8
|
|
@ -188,13 +188,28 @@ Disallow: /forum/active/
|
||||||
<xhtml:link rel="alternate" hreflang="en"/><!-- wrong tag without href -->
|
<xhtml:link rel="alternate" hreflang="en"/><!-- wrong tag without href -->
|
||||||
</url>
|
</url>
|
||||||
</urlset>""")
|
</urlset>""")
|
||||||
|
|
||||||
self.assertEqual(list(s), [
|
self.assertEqual(list(s), [
|
||||||
{'loc': 'http://www.example.com/english/',
|
{'loc': 'http://www.example.com/english/',
|
||||||
'alternate': ['http://www.example.com/deutsch/', 'http://www.example.com/schweiz-deutsch/', 'http://www.example.com/english/']
|
'alternate': ['http://www.example.com/deutsch/', 'http://www.example.com/schweiz-deutsch/', 'http://www.example.com/english/']
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_xml_entity_expansion(self):
|
||||||
|
s = Sitemap("""<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE foo [
|
||||||
|
<!ELEMENT foo ANY >
|
||||||
|
<!ENTITY xxe SYSTEM "file:///etc/passwd" >
|
||||||
|
]>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||||
|
<url>
|
||||||
|
<loc>http://127.0.0.1:8000/&xxe;</loc>
|
||||||
|
</url>
|
||||||
|
</urlset>
|
||||||
|
""")
|
||||||
|
|
||||||
|
self.assertEqual(list(s), [{'loc': 'http://127.0.0.1:8000/'}])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue