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
873c5832
Kaydet (Commit)
873c5832
authored
Haz 09, 2011
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#10694: zipfile now ignores garbage at the end of a zipfile.
Original fix by 'rep', final patch (with tests) by Xuanji Li.
üst
5446f08c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
10 deletions
+28
-10
test_zipfile.py
Lib/test/test_zipfile.py
+18
-0
zipfile.py
Lib/zipfile.py
+8
-10
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_zipfile.py
Dosyayı görüntüle @
873c5832
...
@@ -335,6 +335,24 @@ class TestsWithSourceFile(unittest.TestCase):
...
@@ -335,6 +335,24 @@ class TestsWithSourceFile(unittest.TestCase):
with
zipfile
.
ZipFile
(
f
,
"r"
)
as
zipfp
:
with
zipfile
.
ZipFile
(
f
,
"r"
)
as
zipfp
:
self
.
assertEqual
(
zipfp
.
namelist
(),
[
TESTFN
])
self
.
assertEqual
(
zipfp
.
namelist
(),
[
TESTFN
])
def
test_ignores_newline_at_end
(
self
):
with
zipfile
.
ZipFile
(
TESTFN2
,
"w"
,
zipfile
.
ZIP_STORED
)
as
zipfp
:
zipfp
.
write
(
TESTFN
,
TESTFN
)
with
open
(
TESTFN2
,
'a'
)
as
f
:
f
.
write
(
"
\r\n\00\00\00
"
)
with
zipfile
.
ZipFile
(
TESTFN2
,
"r"
)
as
zipfp
:
self
.
assertIsInstance
(
zipfp
,
zipfile
.
ZipFile
)
def
test_ignores_stuff_appended_past_comments
(
self
):
with
zipfile
.
ZipFile
(
TESTFN2
,
"w"
,
zipfile
.
ZIP_STORED
)
as
zipfp
:
zipfp
.
comment
=
b
"this is a comment"
zipfp
.
write
(
TESTFN
,
TESTFN
)
with
open
(
TESTFN2
,
'a'
)
as
f
:
f
.
write
(
"abcdef
\r\n
"
)
with
zipfile
.
ZipFile
(
TESTFN2
,
"r"
)
as
zipfp
:
self
.
assertIsInstance
(
zipfp
,
zipfile
.
ZipFile
)
self
.
assertEqual
(
zipfp
.
comment
,
b
"this is a comment"
)
def
test_write_default_name
(
self
):
def
test_write_default_name
(
self
):
"""Check that calling ZipFile.write without arcname specified
"""Check that calling ZipFile.write without arcname specified
produces the expected result."""
produces the expected result."""
...
...
Lib/zipfile.py
Dosyayı görüntüle @
873c5832
...
@@ -236,16 +236,14 @@ def _EndRecData(fpin):
...
@@ -236,16 +236,14 @@ def _EndRecData(fpin):
# found the magic number; attempt to unpack and interpret
# found the magic number; attempt to unpack and interpret
recData
=
data
[
start
:
start
+
sizeEndCentDir
]
recData
=
data
[
start
:
start
+
sizeEndCentDir
]
endrec
=
list
(
struct
.
unpack
(
structEndArchive
,
recData
))
endrec
=
list
(
struct
.
unpack
(
structEndArchive
,
recData
))
comment
=
data
[
start
+
sizeEndCentDir
:]
commentSize
=
endrec
[
_ECD_COMMENT_SIZE
]
#as claimed by the zip file
# check that comment length is correct
comment
=
data
[
start
+
sizeEndCentDir
:
start
+
sizeEndCentDir
+
commentSize
]
if
endrec
[
_ECD_COMMENT_SIZE
]
==
len
(
comment
):
endrec
.
append
(
comment
)
# Append the archive comment and start offset
endrec
.
append
(
maxCommentStart
+
start
)
endrec
.
append
(
comment
)
endrec
.
append
(
maxCommentStart
+
start
)
# Try to read the "Zip64 end of central directory" structure
return
_EndRecData64
(
fpin
,
maxCommentStart
+
start
-
filesize
,
# Try to read the "Zip64 end of central directory" structure
endrec
)
return
_EndRecData64
(
fpin
,
maxCommentStart
+
start
-
filesize
,
endrec
)
# Unable to find a valid end of central directory structure
# Unable to find a valid end of central directory structure
return
return
...
...
Misc/NEWS
Dosyayı görüntüle @
873c5832
...
@@ -16,6 +16,8 @@ Core and Builtins
...
@@ -16,6 +16,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #10694: zipfile now ignores garbage at the end of a zipfile.
- Issue #11583: Speed up os.path.isdir on Windows by using GetFileAttributes
- Issue #11583: Speed up os.path.isdir on Windows by using GetFileAttributes
instead of os.stat.
instead of os.stat.
...
...
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