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
011525ee
Kaydet (Commit)
011525ee
authored
Nis 28, 2011
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix closes issue10761: tarfile.extractall failure when symlinked files are present.
üst
bdfa2e69
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
+32
-0
tarfile.py
Lib/tarfile.py
+2
-0
test_tarfile.py
Lib/test/test_tarfile.py
+27
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/tarfile.py
Dosyayı görüntüle @
011525ee
...
...
@@ -2239,6 +2239,8 @@ class TarFile(object):
if
hasattr
(
os
,
"symlink"
)
and
hasattr
(
os
,
"link"
):
# For systems that support symbolic and hard links.
if
tarinfo
.
issym
():
if
os
.
path
.
exists
(
targetpath
):
os
.
unlink
(
targetpath
)
os
.
symlink
(
tarinfo
.
linkname
,
targetpath
)
else
:
# See extract().
...
...
Lib/test/test_tarfile.py
Dosyayı görüntüle @
011525ee
...
...
@@ -843,6 +843,33 @@ class WriteTest(WriteTestBase):
finally
:
os
.
chdir
(
cwd
)
def
test_extractall_symlinks
(
self
):
# Test if extractall works properly when tarfile contains symlinks
tempdir
=
os
.
path
.
join
(
TEMPDIR
,
"testsymlinks"
)
temparchive
=
os
.
path
.
join
(
TEMPDIR
,
"testsymlinks.tar"
)
os
.
mkdir
(
tempdir
)
try
:
source_file
=
os
.
path
.
join
(
tempdir
,
'source'
)
target_file
=
os
.
path
.
join
(
tempdir
,
'symlink'
)
with
open
(
source_file
,
'w'
)
as
f
:
f
.
write
(
'something
\n
'
)
os
.
symlink
(
source_file
,
target_file
)
tar
=
tarfile
.
open
(
temparchive
,
'w'
)
tar
.
add
(
source_file
,
arcname
=
os
.
path
.
basename
(
source_file
))
tar
.
add
(
target_file
,
arcname
=
os
.
path
.
basename
(
target_file
))
tar
.
close
()
# Let's extract it to the location which contains the symlink
tar
=
tarfile
.
open
(
temparchive
,
'r'
)
# this should not raise OSError: [Errno 17] File exists
try
:
tar
.
extractall
(
path
=
tempdir
)
except
OSError
:
self
.
fail
(
"extractall failed with symlinked files"
)
finally
:
tar
.
close
()
finally
:
os
.
unlink
(
temparchive
)
shutil
.
rmtree
(
tempdir
)
class
StreamWriteTest
(
WriteTestBase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
011525ee
...
...
@@ -65,6 +65,9 @@ Core and Builtins
Library
-------
-
Issue
#
10761
:
Fix
tarfile
.
extractall
failure
when
symlinked
files
are
present
.
Initial
patch
by
Scott
Leerssen
.
-
Issue
#
11763
:
don
't use difflib in TestCase.assertMultiLineEqual if the
strings are too long.
...
...
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