mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #24625 -- Prevented arbitrary file inclusion in admindocs
Thanks Tim Graham for the review.
This commit is contained in:
parent
4e7ed8d0d3
commit
09595b4fc6
5 changed files with 18 additions and 1 deletions
0
tests/admin_docs/evilfile.txt
Normal file
0
tests/admin_docs/evilfile.txt
Normal file
|
@ -29,6 +29,12 @@ class Person(models.Model):
|
|||
Field storing :model:`myapp.Company` where the person works.
|
||||
|
||||
(DESCRIPTION)
|
||||
|
||||
.. raw:: html
|
||||
:file: admin_docs/evilfile.txt
|
||||
|
||||
.. include:: admin_docs/evilfile.txt
|
||||
|
||||
"""
|
||||
first_name = models.CharField(max_length=200, help_text="The person's first name")
|
||||
last_name = models.CharField(max_length=200, help_text="The person's last name")
|
||||
|
|
|
@ -290,6 +290,12 @@ class TestModelDetailView(TestDataMixin, AdminDocsTestCase):
|
|||
"all related %s objects" % (link % ("admin_docs.group", "admin_docs.Group"))
|
||||
)
|
||||
|
||||
# "raw" and "include" directives are disabled
|
||||
self.assertContains(self.response, '<p>"raw" directive disabled.</p>',)
|
||||
self.assertContains(self.response, '.. raw:: html\n :file: admin_docs/evilfile.txt')
|
||||
self.assertContains(self.response, '<p>"include" directive disabled.</p>',)
|
||||
self.assertContains(self.response, '.. include:: admin_docs/evilfile.txt')
|
||||
|
||||
def test_model_with_many_to_one(self):
|
||||
link = '<a class="reference external" href="/admindocs/models/%s/">%s</a>'
|
||||
response = self.client.get(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue