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
0d713497
Kaydet (Commit)
0d713497
authored
Haz 09, 2014
tarafından
David Wolever
Kaydeden (comit)
Tim Graham
Tem 07, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #22804 -- Added warning for unsafe value of 'sep' in Signer
Thanks Jaap Roes for completing the patch.
üst
6bd84623
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
1 deletion
+33
-1
signing.py
django/core/signing.py
+9
-1
deprecation.txt
docs/internals/deprecation.txt
+3
-0
1.9.txt
docs/releases/1.9.txt
+3
-0
tests.py
tests/signing/tests.py
+18
-0
No files found.
django/core/signing.py
Dosyayı görüntüle @
0d713497
...
...
@@ -38,15 +38,20 @@ from __future__ import unicode_literals
import
base64
import
datetime
import
json
import
re
import
time
import
warnings
import
zlib
from
django.conf
import
settings
from
django.utils
import
baseconv
from
django.utils.crypto
import
constant_time_compare
,
salted_hmac
from
django.utils.deprecation
import
RemovedInDjango110Warning
from
django.utils.encoding
import
force_bytes
,
force_str
,
force_text
from
django.utils.module_loading
import
import_string
_SEP_UNSAFE
=
re
.
compile
(
r'^[A-z0-9-_=]*$'
)
class
BadSignature
(
Exception
):
"""
...
...
@@ -150,8 +155,11 @@ class Signer(object):
def
__init__
(
self
,
key
=
None
,
sep
=
':'
,
salt
=
None
):
# Use of native strings in all versions of Python
self
.
sep
=
force_str
(
sep
)
self
.
key
=
key
or
settings
.
SECRET_KEY
self
.
sep
=
force_str
(
sep
)
if
_SEP_UNSAFE
.
match
(
self
.
sep
):
warnings
.
warn
(
'Unsafe Signer separator:
%
r (cannot be empty or consist of only A-z0-9-_=)'
%
sep
,
RemovedInDjango110Warning
)
self
.
salt
=
force_str
(
salt
or
'
%
s.
%
s'
%
(
self
.
__class__
.
__module__
,
self
.
__class__
.
__name__
))
...
...
docs/internals/deprecation.txt
Dosyayı görüntüle @
0d713497
...
...
@@ -247,6 +247,9 @@ details on these changes.
* Support for the syntax of ``{% cycle %}`` that uses comma-separated arguments
will be removed.
* The warning that :class:`~django.core.signing.Signer` issues when given an
invalid separator will become an exception.
.. _deprecation-removed-in-1.9:
1.9
...
...
docs/releases/1.9.txt
Dosyayı görüntüle @
0d713497
...
...
@@ -974,6 +974,9 @@ Miscellaneous
``django.utils.feedgenerator.RssFeed.mime_type`` attributes are deprecated in
favor of ``content_type``.
* :class:`~django.core.signing.Signer` now issues a warning if an invalid
separator is used. This will become an exception in Django 1.10.
.. removed-features-1.9:
Features removed in 1.9
...
...
tests/signing/tests.py
Dosyayı görüntüle @
0d713497
from
__future__
import
unicode_literals
import
datetime
import
warnings
from
django.core
import
signing
from
django.test
import
SimpleTestCase
...
...
@@ -112,6 +113,23 @@ class TestSigner(SimpleTestCase):
s
=
signing
.
Signer
(
binary_key
)
self
.
assertEqual
(
'foo:6NB0fssLW5RQvZ3Y-MTerq2rX7w'
,
s
.
sign
(
'foo'
))
def
test_valid_sep
(
self
):
separators
=
[
'/'
,
'*sep*'
,
','
]
for
sep
in
separators
:
signer
=
signing
.
Signer
(
'predictable-secret'
,
sep
=
sep
)
self
.
assertEqual
(
'foo
%
ssH9B01cZcJ9FoT_jEVkRkNULrl8'
%
sep
,
signer
.
sign
(
'foo'
))
def
test_invalid_sep
(
self
):
"""should warn on invalid separator"""
separators
=
[
''
,
'-'
,
'abc'
]
for
sep
in
separators
:
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
warnings
.
simplefilter
(
'always'
)
signing
.
Signer
(
sep
=
sep
)
self
.
assertEqual
(
len
(
recorded
),
1
)
msg
=
str
(
recorded
[
0
]
.
message
)
self
.
assertTrue
(
msg
.
startswith
(
'Unsafe Signer separator'
))
class
TestTimestampSigner
(
SimpleTestCase
):
...
...
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