Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
2f16ff5a
Kaydet (Commit)
2f16ff5a
authored
Eki 04, 2014
tarafından
Markus Holtermann
Kaydeden (comit)
Tim Graham
Eki 06, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23601 -- Ensured view exists in URLconf before importing it in admindocs.
üst
a24cf217
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
4 deletions
+29
-4
views.py
django/contrib/admindocs/views.py
+4
-3
urlresolvers.py
django/core/urlresolvers.py
+6
-1
1.8.txt
docs/releases/1.8.txt
+8
-0
tests.py
tests/admin_docs/tests.py
+11
-0
No files found.
django/contrib/admindocs/views.py
Dosyayı görüntüle @
2f16ff5a
...
...
@@ -143,10 +143,11 @@ class ViewDetailView(BaseAdminDocsView):
def
get_context_data
(
self
,
**
kwargs
):
view
=
self
.
kwargs
[
'view'
]
mod
,
func
=
urlresolvers
.
get_mod_func
(
view
)
try
:
urlconf
=
urlresolvers
.
get_urlconf
()
if
urlresolvers
.
get_resolver
(
urlconf
)
.
_is_callback
(
view
):
mod
,
func
=
urlresolvers
.
get_mod_func
(
view
)
view_func
=
getattr
(
import_module
(
mod
),
func
)
e
xcept
(
ImportError
,
AttributeError
)
:
e
lse
:
raise
Http404
title
,
body
,
metadata
=
utils
.
parse_docstring
(
view_func
.
__doc__
)
if
title
:
...
...
django/core/urlresolvers.py
Dosyayı görüntüle @
2f16ff5a
...
...
@@ -353,6 +353,11 @@ class RegexURLResolver(LocaleRegexProvider):
self
.
_populate
()
return
self
.
_app_dict
[
language_code
]
def
_is_callback
(
self
,
name
):
if
not
self
.
_populated
:
self
.
_populate
()
return
name
in
self
.
_callback_strs
def
resolve
(
self
,
path
):
path
=
force_text
(
path
)
# path may be a reverse_lazy object
tried
=
[]
...
...
@@ -430,7 +435,7 @@ class RegexURLResolver(LocaleRegexProvider):
original_lookup
=
lookup_view
try
:
if
lookup_view
in
self
.
_callback_strs
:
if
self
.
_is_callback
(
lookup_view
)
:
lookup_view
=
get_callable
(
lookup_view
,
True
)
except
(
ImportError
,
AttributeError
)
as
e
:
raise
NoReverseMatch
(
"Error importing '
%
s':
%
s."
%
(
lookup_view
,
e
))
...
...
docs/releases/1.8.txt
Dosyayı görüntüle @
2f16ff5a
...
...
@@ -76,6 +76,14 @@ Minor features
<django.contrib.admin.ModelAdmin.show_full_result_count>` to control whether
or not the full count of objects should be displayed on a filtered admin page.
:mod:`django.contrib.admindocs`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* The view to browse view details now checks if the view specified in the URL
exists in the URLconf. Previously it was possible to import arbitrary
packages from the Python path. This was not considered a security issue
because ``admindocs`` is only accessible to staff users.
:mod:`django.contrib.auth`
^^^^^^^^^^^^^^^^^^^^^^^^^^
...
...
tests/admin_docs/tests.py
Dosyayı görüntüle @
2f16ff5a
import
sys
import
unittest
from
django.conf
import
settings
...
...
@@ -84,6 +85,16 @@ class AdminDocViewTests(AdminDocsTestCase):
# View docstring
self
.
assertContains
(
response
,
'Base view for admindocs views.'
)
def
test_view_detail_illegal_import
(
self
):
"""
#23601 - Ensure the view exists in the URLconf.
"""
response
=
self
.
client
.
get
(
reverse
(
'django-admindocs-views-detail'
,
args
=
[
'urlpatterns_reverse.nonimported_module.view'
]))
self
.
assertEqual
(
response
.
status_code
,
404
)
self
.
assertNotIn
(
"urlpatterns_reverse.nonimported_module"
,
sys
.
modules
)
def
test_model_index
(
self
):
response
=
self
.
client
.
get
(
reverse
(
'django-admindocs-models-index'
))
self
.
assertContains
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment