From 8d6e0d45882444cf528b10832811fa19613f184a Mon Sep 17 00:00:00 2001 From: Alexandr Shurigin Date: Thu, 22 May 2014 19:12:22 +0700 Subject: [PATCH] [1.7.x] Fixed #22681 -- Made TarArchive recognize leading directories properly. Backport of 083d285b82 from master --- django/utils/archive.py | 2 +- tests/utils_tests/archives/leadpath_foobar.tar | Bin 0 -> 5632 bytes .../utils_tests/archives/leadpath_foobar.tar.bz2 | Bin 0 -> 265 bytes .../utils_tests/archives/leadpath_foobar.tar.gz | Bin 0 -> 265 bytes tests/utils_tests/archives/leadpath_foobar.zip | Bin 0 -> 1402 bytes tests/utils_tests/test_archive.py | 5 +++++ 6 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/utils_tests/archives/leadpath_foobar.tar create mode 100644 tests/utils_tests/archives/leadpath_foobar.tar.bz2 create mode 100644 tests/utils_tests/archives/leadpath_foobar.tar.gz create mode 100644 tests/utils_tests/archives/leadpath_foobar.zip diff --git a/django/utils/archive.py b/django/utils/archive.py index 90b72593a9..6a47b00502 100644 --- a/django/utils/archive.py +++ b/django/utils/archive.py @@ -144,7 +144,7 @@ class TarArchive(BaseArchive): # note: python<=2.5 doesn't seem to know about pax headers, filter them members = [member for member in self._archive.getmembers() if member.name != 'pax_global_header'] - leading = self.has_leading_dir(members) + leading = self.has_leading_dir(x.name for x in members) for member in members: name = member.name if leading: diff --git a/tests/utils_tests/archives/leadpath_foobar.tar b/tests/utils_tests/archives/leadpath_foobar.tar new file mode 100644 index 0000000000000000000000000000000000000000..3ff38d72f5fba4567480454726cf451206b0d830 GIT binary patch literal 5632 zcmeH~+X{m)42FG_zQNK{`aF(qAh-!`zW>sCK#CU@4D2GksmVo1^Z6%j|7c_E##_U< z03dj;nzZA*YXjLPS6)gR>%eO3gI1u8H=$9UF{dr`^!c_Ur5307*qjF+ZG3g_1OMt; z&XEpDOResI-}{BXW=xdofzF-ePd^IrM=*^7#+|1Vi_*n9q5GoVWU!Dar4qJIwFWz0Q)t{G6rA2a`; zg@4J4!`}11w>IESy#Pi3B`XfQiB2< W>-7GY`#%S9i76G33P=U!3j6>p_|UHa literal 0 HcmV?d00001 diff --git a/tests/utils_tests/archives/leadpath_foobar.tar.bz2 b/tests/utils_tests/archives/leadpath_foobar.tar.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..15f47ca179937f8a9507196fc1dab607de8cec40 GIT binary patch literal 265 zcmV+k0rvhvT4*^jL0KkKS@Yb`v;YC=|B%pt0Kh;1|9}7h%)oaio&W?u00=MvBSi?5 z2qI|p8Uc{dXkgPunqe_AU?6FMQl_8)06jnhC&C`cYr9%fl%+UtBqTS1)Fyz7jkeP| zn^Pb|q8X~{qXakzQ467hLP;z++SIm%XKEO8=?MuV2T{>SdKpkr!fb_zb8>N3wZjZ@ zC6LKTW`#Avw4^MfLp~6cOlgbA=M7_ Pf5qI9P81|O_cSd4>(g)0 literal 0 HcmV?d00001 diff --git a/tests/utils_tests/archives/leadpath_foobar.tar.gz b/tests/utils_tests/archives/leadpath_foobar.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..7b5ba7eda429f618998d63c6d72e088620bc01e3 GIT binary patch literal 265 zcmV+k0rvhMiwFQJn1NFO1MSyM3c@fD1>hbfH*oSdIZq`Dg=(SN`}|^14ylSVvY{AGAul-h@VZ$wO_X$Fm*NQQ{OY zN1tost-BxWuixXn{)v9gUkg4Xy$^Qo%ly+1CG9eqMv>r|-jILJ-v~aVD1WA0{~;j% z8n*ne!yq;TO8P(3-2bg5hyGu~K7XkhP*nfH<@}jZ|26FMmzn`(`E$-cXyjkRKL2wo z^FN@h|Ihh5@*e%ahR^&ZWB&JCn(_+u3!Onvjq~@?*Z;FX>qrZ37+WH&u>K* zzZco#(+&jDA^?a|d^cSRnGj-4XqUtt5}}LeI*3k5-1~?tLF{T%T#rVarSN6B5XzoV zIM2j4%%z9nOfNnr7fd3i>F3oRz4~%VscDfo+jP^RY!v6CsjS-`)DFYH+ILX(FoB