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
d13881bd
Kaydet (Commit)
d13881bd
authored
Haz 21, 2016
tarafından
Jon Dufresne
Kaydeden (comit)
Tim Graham
Haz 21, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26783 -- Fixed SessionMiddleware's empty cookie deletion when using SESSION_COOKIE_PATH.
üst
140c2350
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
middleware.py
django/contrib/sessions/middleware.py
+5
-1
tests.py
tests/sessions_tests/tests.py
+6
-5
No files found.
django/contrib/sessions/middleware.py
Dosyayı görüntüle @
d13881bd
...
...
@@ -35,7 +35,11 @@ class SessionMiddleware(MiddlewareMixin):
# First check if we need to delete this cookie.
# The session should be deleted only if the session is entirely empty
if
settings
.
SESSION_COOKIE_NAME
in
request
.
COOKIES
and
empty
:
response
.
delete_cookie
(
settings
.
SESSION_COOKIE_NAME
,
domain
=
settings
.
SESSION_COOKIE_DOMAIN
)
response
.
delete_cookie
(
settings
.
SESSION_COOKIE_NAME
,
path
=
settings
.
SESSION_COOKIE_PATH
,
domain
=
settings
.
SESSION_COOKIE_DOMAIN
,
)
else
:
if
accessed
:
patch_vary_headers
(
response
,
(
'Cookie'
,))
...
...
tests/sessions_tests/tests.py
Dosyayı görüntüle @
d13881bd
...
...
@@ -746,8 +746,8 @@ class SessionMiddlewareTests(TestCase):
str
(
response
.
cookies
[
settings
.
SESSION_COOKIE_NAME
])
)
@override_settings
(
SESSION_COOKIE_DOMAIN
=
'.example.local'
)
def
test_session_delete_on_end_with_custom_domain
(
self
):
@override_settings
(
SESSION_COOKIE_DOMAIN
=
'.example.local'
,
SESSION_COOKIE_PATH
=
'/example/'
)
def
test_session_delete_on_end_with_custom_domain
_and_path
(
self
):
request
=
RequestFactory
()
.
get
(
'/'
)
response
=
HttpResponse
(
'Session test'
)
middleware
=
SessionMiddleware
()
...
...
@@ -763,12 +763,13 @@ class SessionMiddlewareTests(TestCase):
response
=
middleware
.
process_response
(
request
,
response
)
# Check that the cookie was deleted, not recreated.
# A deleted cookie header with a custom domain looks like:
# A deleted cookie header with a custom domain
and path
looks like:
# Set-Cookie: sessionid=; Domain=.example.local;
# expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
# expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0;
# Path=/example/
self
.
assertEqual
(
'Set-Cookie: {}={}; Domain=.example.local; expires=Thu, '
'01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/'
.
format
(
'01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
example/
'
.
format
(
settings
.
SESSION_COOKIE_NAME
,
'""'
if
sys
.
version_info
>=
(
3
,
5
)
else
''
,
),
...
...
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