Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(32766)

Unified Diff: Lib/test/test_tarfile.py

Issue 23228: Crashes when tarfile contains a symlink and unpack directory contain it too
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Lib/tarfile.py ('K') | « Lib/tarfile.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -525,12 +525,21 @@
data = f.read()
self.assertEqual(md5sum(data), md5_regtype)
+ @support.skip_unless_symlink
+ def test_extract_symlink(self):
+ # Test symlink extraction (e.g. bug #23228).
+ with tarfile.open(tarname, errorlevel=1, encoding="iso8859-1") as tar:
+ tar.extract("ustar/regtype", TEMPDIR)
+ self.addCleanup(support.unlink, os.path.join(TEMPDIR, "ustar/regtype"))
+
tar.extract("ustar/symtype", TEMPDIR)
self.addCleanup(support.unlink, os.path.join(TEMPDIR, "ustar/symtype"))
with open(os.path.join(TEMPDIR, "ustar/symtype"), "rb") as f:
data = f.read()
self.assertEqual(md5sum(data), md5_regtype)
+ self.assertRaises(FileExistsError, tar.extract, "ustar/symtype", TEMPDIR)
+
def test_extractall(self):
# Test if extractall() correctly restores directory permissions
# and times (see issue1735).
« Lib/tarfile.py ('K') | « Lib/tarfile.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+