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
96107e28
Kaydet (Commit)
96107e28
authored
Eyl 03, 2017
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #26956 -- Removed the host parameter of django.utils.http.is_safe_url().
Per deprecation timeline.
üst
e47b56d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
17 deletions
+3
-17
http.py
django/utils/http.py
+1
-11
2.1.txt
docs/releases/2.1.txt
+2
-0
test_http.py
tests/utils_tests/test_http.py
+0
-6
No files found.
django/utils/http.py
Dosyayı görüntüle @
96107e28
...
...
@@ -3,7 +3,6 @@ import calendar
import
datetime
import
re
import
unicodedata
import
warnings
from
binascii
import
Error
as
BinasciiError
from
email.utils
import
formatdate
from
urllib.parse
import
(
...
...
@@ -14,7 +13,6 @@ from urllib.parse import (
from
django.core.exceptions
import
TooManyFieldsSent
from
django.utils.datastructures
import
MultiValueDict
from
django.utils.deprecation
import
RemovedInDjango21Warning
from
django.utils.encoding
import
force_bytes
from
django.utils.functional
import
keep_lazy_text
...
...
@@ -264,7 +262,7 @@ def is_same_domain(host, pattern):
)
def
is_safe_url
(
url
,
host
=
None
,
allowed_hosts
=
None
,
require_https
=
False
):
def
is_safe_url
(
url
,
allowed_hosts
=
None
,
require_https
=
False
):
"""
Return ``True`` if the url is a safe redirection (i.e. it doesn't point to
a different host and uses a safe scheme).
...
...
@@ -280,14 +278,6 @@ def is_safe_url(url, host=None, allowed_hosts=None, require_https=False):
return
False
if
allowed_hosts
is
None
:
allowed_hosts
=
set
()
if
host
:
warnings
.
warn
(
"The host argument is deprecated, use allowed_hosts instead."
,
RemovedInDjango21Warning
,
stacklevel
=
2
,
)
# Avoid mutating the passed in allowed_hosts.
allowed_hosts
=
allowed_hosts
|
{
host
}
# Chrome treats \ completely as / in paths but it could be part of some
# basic auth credentials so we need to check both URLs.
return
(
_is_safe_url
(
url
,
allowed_hosts
,
require_https
=
require_https
)
and
...
...
docs/releases/2.1.txt
Dosyayı görüntüle @
96107e28
...
...
@@ -239,3 +239,5 @@ how to remove usage of these features.
* ``django.core.cache.backends.memcached.PyLibMCCache`` no longer supports
passing ``pylibmc`` behavior settings as top-level attributes of ``OPTIONS``.
* The ``host`` parameter of ``django.utils.http.is_safe_url()`` is removed.
tests/utils_tests/test_http.py
Dosyayı görüntüle @
96107e28
import
unittest
from
datetime
import
datetime
from
django.test
import
ignore_warnings
from
django.utils
import
http
from
django.utils.datastructures
import
MultiValueDict
from
django.utils.deprecation
import
RemovedInDjango21Warning
class
TestUtilsHttp
(
unittest
.
TestCase
):
...
...
@@ -107,8 +105,6 @@ class TestUtilsHttp(unittest.TestCase):
'http://2001:cdba:0000:0000:0000:0000:3257:9652]/'
,
)
for
bad_url
in
bad_urls
:
with
ignore_warnings
(
category
=
RemovedInDjango21Warning
):
self
.
assertFalse
(
http
.
is_safe_url
(
bad_url
,
host
=
'testserver'
),
"
%
s should be blocked"
%
bad_url
)
self
.
assertFalse
(
http
.
is_safe_url
(
bad_url
,
allowed_hosts
=
{
'testserver'
,
'testserver2'
}),
"
%
s should be blocked"
%
bad_url
,
...
...
@@ -127,8 +123,6 @@ class TestUtilsHttp(unittest.TestCase):
'path/http:2222222222'
,
)
for
good_url
in
good_urls
:
with
ignore_warnings
(
category
=
RemovedInDjango21Warning
):
self
.
assertTrue
(
http
.
is_safe_url
(
good_url
,
host
=
'testserver'
),
"
%
s should be allowed"
%
good_url
)
self
.
assertTrue
(
http
.
is_safe_url
(
good_url
,
allowed_hosts
=
{
'otherserver'
,
'testserver'
}),
"
%
s should be allowed"
%
good_url
,
...
...
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