Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
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
cpython
Commits
d099b56b
Kaydet (Commit)
d099b56b
authored
May 01, 2012
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Check extract_version when opening a zipfile.
üst
67c14444
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
test_zipfile.py
Lib/test/test_zipfile.py
+10
-0
zipfile.py
Lib/zipfile.py
+5
-0
No files found.
Lib/test/test_zipfile.py
Dosyayı görüntüle @
d099b56b
...
...
@@ -828,6 +828,16 @@ class OtherTests(unittest.TestCase):
b
'
\x00\x00\x00\x00
'
),
}
def
test_unsupported_version
(
self
):
# File has an extract_version of 120
data
=
(
b
'PK
\x03\x04
x
\x00\x00\x00\x00\x00
!p
\xa1
@
\x00\x00\x00\x00\x00\x00
'
b
'
\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00
xPK
\x01\x02
x
\x03
x
\x00\x00\x00\x00
'
b
'
\x00
!p
\xa1
@
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00
'
b
'
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x01\x00\x00\x00\x00
xPK
\x05\x06
'
b
'
\x00\x00\x00\x00\x01\x00\x01\x00
/
\x00\x00\x00\x1f\x00\x00\x00\x00\x00
'
)
self
.
assertRaises
(
NotImplementedError
,
zipfile
.
ZipFile
,
io
.
BytesIO
(
data
),
'r'
)
def
test_unicode_filenames
(
self
):
with
zipfile
.
ZipFile
(
TESTFN
,
"w"
)
as
zf
:
zf
.
writestr
(
"foo.txt"
,
"Test for unicode filename"
)
...
...
Lib/zipfile.py
Dosyayı görüntüle @
d099b56b
...
...
@@ -57,6 +57,8 @@ ZIP_BZIP2 = 12
DEFAULT_VERSION
=
20
ZIP64_VERSION
=
45
BZIP2_VERSION
=
46
# we recognize (but not necessarily support) all features up to that version
MAX_EXTRACT_VERSION
=
46
# Below are some formats and associated data for reading/writing headers using
# the struct module. The names and structures of headers/records are those used
...
...
@@ -920,6 +922,9 @@ class ZipFile:
(
x
.
create_version
,
x
.
create_system
,
x
.
extract_version
,
x
.
reserved
,
x
.
flag_bits
,
x
.
compress_type
,
t
,
d
,
x
.
CRC
,
x
.
compress_size
,
x
.
file_size
)
=
centdir
[
1
:
12
]
if
x
.
extract_version
>
MAX_EXTRACT_VERSION
:
raise
NotImplementedError
(
"zip file version
%.1
f"
%
(
x
.
extract_version
/
10
))
x
.
volume
,
x
.
internal_attr
,
x
.
external_attr
=
centdir
[
15
:
18
]
# Convert date/time code to (year, month, day, hour, min, sec)
x
.
_raw_time
=
t
...
...
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