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
a849ec18
Kaydet (Commit)
a849ec18
authored
Ara 17, 2016
tarafından
Jerome Leclanche
Kaydeden (comit)
Tim Graham
Ara 19, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27606 -- Fixed HttpResponseRedirect.__repr__() crash when DisallowedRedirect is raised.
üst
6af23a45
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
response.py
django/http/response.py
+2
-2
tests.py
tests/httpwrappers/tests.py
+12
-1
No files found.
django/http/response.py
Dosyayı görüntüle @
a849ec18
...
...
@@ -420,11 +420,11 @@ class HttpResponseRedirectBase(HttpResponse):
allowed_schemes
=
[
'http'
,
'https'
,
'ftp'
]
def
__init__
(
self
,
redirect_to
,
*
args
,
**
kwargs
):
super
(
HttpResponseRedirectBase
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
[
'Location'
]
=
iri_to_uri
(
redirect_to
)
parsed
=
urlparse
(
force_text
(
redirect_to
))
if
parsed
.
scheme
and
parsed
.
scheme
not
in
self
.
allowed_schemes
:
raise
DisallowedRedirect
(
"Unsafe redirect to URL with protocol '
%
s'"
%
parsed
.
scheme
)
super
(
HttpResponseRedirectBase
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
[
'Location'
]
=
iri_to_uri
(
redirect_to
)
url
=
property
(
lambda
self
:
self
[
'Location'
])
...
...
tests/httpwrappers/tests.py
Dosyayı görüntüle @
a849ec18
...
...
@@ -8,7 +8,7 @@ import pickle
import
unittest
import
uuid
from
django.core.exceptions
import
SuspiciousOperation
from
django.core.exceptions
import
DisallowedRedirect
,
SuspiciousOperation
from
django.core.serializers.json
import
DjangoJSONEncoder
from
django.core.signals
import
request_finished
from
django.db
import
close_old_connections
...
...
@@ -517,6 +517,17 @@ class HttpResponseSubclassesTests(SimpleTestCase):
expected
=
'<HttpResponseRedirect status_code=302, "text/html; charset=utf-8", url="/redirected/">'
self
.
assertEqual
(
repr
(
response
),
expected
)
def
test_invalid_redirect_repr
(
self
):
"""
If HttpResponseRedirect raises DisallowedRedirect, its __repr__()
should work (in the debug view, for example).
"""
response
=
HttpResponseRedirect
.
__new__
(
HttpResponseRedirect
)
with
self
.
assertRaisesMessage
(
DisallowedRedirect
,
"Unsafe redirect to URL with protocol 'ssh'"
):
HttpResponseRedirect
.
__init__
(
response
,
'ssh://foo'
)
expected
=
'<HttpResponseRedirect status_code=302, "text/html; charset=utf-8", url="ssh://foo">'
self
.
assertEqual
(
repr
(
response
),
expected
)
def
test_not_modified
(
self
):
response
=
HttpResponseNotModified
()
self
.
assertEqual
(
response
.
status_code
,
304
)
...
...
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