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
47a99d70
Kaydet (Commit)
47a99d70
authored
Ock 04, 2018
tarafından
Alvin Lindstam
Kaydeden (comit)
Tim Graham
Ock 08, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28989 -- Fixed HttpResponse.delete_cookie() for cookies that use __Secure/Host prefixes.
üst
8e94f9f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
response.py
django/http/response.py
+7
-2
test_cookie.py
tests/responses/test_cookie.py
+13
-0
No files found.
django/http/response.py
Dosyayı görüntüle @
47a99d70
...
@@ -205,8 +205,13 @@ class HttpResponseBase:
...
@@ -205,8 +205,13 @@ class HttpResponseBase:
return
self
.
set_cookie
(
key
,
value
,
**
kwargs
)
return
self
.
set_cookie
(
key
,
value
,
**
kwargs
)
def
delete_cookie
(
self
,
key
,
path
=
'/'
,
domain
=
None
):
def
delete_cookie
(
self
,
key
,
path
=
'/'
,
domain
=
None
):
self
.
set_cookie
(
key
,
max_age
=
0
,
path
=
path
,
domain
=
domain
,
# Most browsers ignore the Set-Cookie header if the cookie name starts
expires
=
'Thu, 01 Jan 1970 00:00:00 GMT'
)
# with __Host- or __Secure- and the cookie doesn't use the secure flag.
secure
=
key
.
startswith
((
'__Secure-'
,
'__Host-'
))
self
.
set_cookie
(
key
,
max_age
=
0
,
path
=
path
,
domain
=
domain
,
secure
=
secure
,
expires
=
'Thu, 01 Jan 1970 00:00:00 GMT'
,
)
# Common methods used by subclasses
# Common methods used by subclasses
...
...
tests/responses/test_cookie.py
Dosyayı görüntüle @
47a99d70
...
@@ -91,3 +91,16 @@ class DeleteCookieTests(SimpleTestCase):
...
@@ -91,3 +91,16 @@ class DeleteCookieTests(SimpleTestCase):
self
.
assertEqual
(
cookie
[
'path'
],
'/'
)
self
.
assertEqual
(
cookie
[
'path'
],
'/'
)
self
.
assertEqual
(
cookie
[
'secure'
],
''
)
self
.
assertEqual
(
cookie
[
'secure'
],
''
)
self
.
assertEqual
(
cookie
[
'domain'
],
''
)
self
.
assertEqual
(
cookie
[
'domain'
],
''
)
def
test_delete_cookie_secure_prefix
(
self
):
"""
delete_cookie() sets the secure flag if the cookie name starts with
__Host- or __Secure- (without that, browsers ignore cookies with those
prefixes).
"""
response
=
HttpResponse
()
for
prefix
in
(
'Secure'
,
'Host'
):
with
self
.
subTest
(
prefix
=
prefix
):
cookie_name
=
'__
%
s-c'
%
prefix
response
.
delete_cookie
(
cookie_name
)
self
.
assertEqual
(
response
.
cookies
[
cookie_name
][
'secure'
],
True
)
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