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
b536dcf6
Kaydet (Commit)
b536dcf6
authored
Mar 17, 2017
tarafından
Tim Graham
Kaydeden (comit)
GitHub
Mar 17, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27948 -- Removed incorrect unquote() in static serving views.
üst
6b4f018b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
12 additions
and
8 deletions
+12
-8
views.py
django/contrib/staticfiles/views.py
+1
-2
static.py
django/views/static.py
+1
-2
%2F.txt
tests/staticfiles_tests/apps/test/static/test/%2F.txt
+1
-0
cases.py
tests/staticfiles_tests/cases.py
+3
-0
test_views.py
tests/staticfiles_tests/test_views.py
+2
-2
%2F.txt
tests/view_tests/media/%2F.txt
+1
-0
test_static.py
tests/view_tests/tests/test_static.py
+3
-2
No files found.
django/contrib/staticfiles/views.py
Dosyayı görüntüle @
b536dcf6
...
...
@@ -5,7 +5,6 @@ development, and SHOULD NOT be used in a production setting.
"""
import
os
import
posixpath
from
urllib.parse
import
unquote
from
django.conf
import
settings
from
django.contrib.staticfiles
import
finders
...
...
@@ -30,7 +29,7 @@ def serve(request, path, insecure=False, **kwargs):
"""
if
not
settings
.
DEBUG
and
not
insecure
:
raise
Http404
normalized_path
=
posixpath
.
normpath
(
unquote
(
path
)
)
.
lstrip
(
'/'
)
normalized_path
=
posixpath
.
normpath
(
path
)
.
lstrip
(
'/'
)
absolute_path
=
finders
.
find
(
normalized_path
)
if
not
absolute_path
:
if
path
.
endswith
(
'/'
)
or
path
==
''
:
...
...
django/views/static.py
Dosyayı görüntüle @
b536dcf6
...
...
@@ -7,7 +7,6 @@ import os
import
posixpath
import
re
import
stat
from
urllib.parse
import
unquote
from
django.http
import
(
FileResponse
,
Http404
,
HttpResponse
,
HttpResponseNotModified
,
...
...
@@ -34,7 +33,7 @@ def serve(request, path, document_root=None, show_indexes=False):
but if you'd like to override it, you can create a template called
``static/directory_index.html``.
"""
path
=
posixpath
.
normpath
(
unquote
(
path
)
)
path
=
posixpath
.
normpath
(
path
)
path
=
path
.
lstrip
(
'/'
)
newpath
=
''
for
part
in
path
.
split
(
'/'
):
...
...
tests/staticfiles_tests/apps/test/static/test/%2F.txt
0 → 100644
Dosyayı görüntüle @
b536dcf6
%2F content
tests/staticfiles_tests/cases.py
Dosyayı görüntüle @
b536dcf6
...
...
@@ -128,3 +128,6 @@ class TestDefaults:
Can find a file with capital letters.
"""
self
.
assertFileContains
(
'test/camelCase.txt'
,
'camelCase'
)
def
test_filename_with_percent_sign
(
self
):
self
.
assertFileContains
(
'test/
%2
F.txt'
,
'
%2
F content'
)
tests/staticfiles_tests/test_views.py
Dosyayı görüntüle @
b536dcf6
import
posixpath
from
urllib.parse
import
quote
from
django.conf
import
settings
from
django.test
import
override_settings
...
...
@@ -12,8 +13,7 @@ class TestServeStatic(StaticFilesTestCase):
Test static asset serving view.
"""
def
_response
(
self
,
filepath
):
return
self
.
client
.
get
(
posixpath
.
join
(
settings
.
STATIC_URL
,
filepath
))
return
self
.
client
.
get
(
quote
(
posixpath
.
join
(
settings
.
STATIC_URL
,
filepath
)))
def
assertFileContains
(
self
,
filepath
,
text
):
self
.
assertContains
(
self
.
_response
(
filepath
),
text
)
...
...
tests/view_tests/media/%2F.txt
0 → 100644
Dosyayı görüntüle @
b536dcf6
%2F content
tests/view_tests/tests/test_static.py
Dosyayı görüntüle @
b536dcf6
import
mimetypes
import
unittest
from
os
import
path
from
urllib.parse
import
quote
from
django.conf.urls.static
import
static
from
django.core.exceptions
import
ImproperlyConfigured
...
...
@@ -21,9 +22,9 @@ class StaticTests(SimpleTestCase):
def
test_serve
(
self
):
"The static view can serve static media"
media_files
=
[
'file.txt'
,
'file.txt.gz'
]
media_files
=
[
'file.txt'
,
'file.txt.gz'
,
'
%2
F.txt'
]
for
filename
in
media_files
:
response
=
self
.
client
.
get
(
'/
%
s/
%
s'
%
(
self
.
prefix
,
filename
))
response
=
self
.
client
.
get
(
'/
%
s/
%
s'
%
(
self
.
prefix
,
quote
(
filename
)
))
response_content
=
b
''
.
join
(
response
)
file_path
=
path
.
join
(
media_dir
,
filename
)
with
open
(
file_path
,
'rb'
)
as
fp
:
...
...
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