From bee9f377bc547c99fe99b4e38199cb92cf668554 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 3 Nov 2012 17:54:02 +0100 Subject: Completely rewritten Tar library This new class is only losely based on our previous library. The whole API was changed to make it more flexible and memory saving. Some fisrt unit tests are included --- _test/tests/inc/tar.test.php | 134 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 _test/tests/inc/tar.test.php (limited to '_test/tests/inc/tar.test.php') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php new file mode 100644 index 000000000..706516d9e --- /dev/null +++ b/_test/tests/inc/tar.test.php @@ -0,0 +1,134 @@ +create(); + $tar->AddFile("$dir/testdata1.txt"); + $tar->AddFile("$dir/foobar/testdata2.txt", 'noway/testdata2.txt'); + $tar->addData('another/testdata3.txt', 'testcontent3'); + + $data = $tar->getArchive(); + + $this->assertTrue(strpos($data, 'testcontent1') !== false, 'Content in TAR'); + $this->assertTrue(strpos($data, 'testcontent2') !== false, 'Content in TAR'); + $this->assertTrue(strpos($data, 'testcontent3') !== false, 'Content in TAR'); + + $this->assertTrue(strpos($data, "$dir/testdata1.txt") !== false, 'Path in TAR'); + $this->assertTrue(strpos($data, 'noway/testdata2.txt') !== false, 'Path in TAR'); + $this->assertTrue(strpos($data, 'another/testdata3.txt') !== false, 'Path in TAR'); + + $this->assertTrue(strpos($data, "$dir/foobar/testdata2.txt") === false, 'Path not in TAR'); + $this->assertTrue(strpos($data, "foobar") === false, 'Path not in TAR'); + } + + /** + * simple test that checks that the given filenames and contents can be grepped from the + * uncompressed tar file + * + * No check for format correctness + */ + public function test_createfile(){ + $tar = new Tar(); + + $dir = dirname(__FILE__).'/tar'; + $tmp = tempnam(sys_get_temp_dir(), 'dwtartest'); + + $tar->create($tmp, Tar::COMPRESS_NONE); + $tar->AddFile("$dir/testdata1.txt"); + $tar->AddFile("$dir/foobar/testdata2.txt", 'noway/testdata2.txt'); + $tar->addData('another/testdata3.txt', 'testcontent3'); + $tar->close(); + + $this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number + $data = file_get_contents($tmp); + + $this->assertTrue(strpos($data, 'testcontent1') !== false, 'Content in TAR'); + $this->assertTrue(strpos($data, 'testcontent2') !== false, 'Content in TAR'); + $this->assertTrue(strpos($data, 'testcontent3') !== false, 'Content in TAR'); + + $this->assertTrue(strpos($data, "$dir/testdata1.txt") !== false, 'Path in TAR'); + $this->assertTrue(strpos($data, 'noway/testdata2.txt') !== false, 'Path in TAR'); + $this->assertTrue(strpos($data, 'another/testdata3.txt') !== false, 'Path in TAR'); + + $this->assertTrue(strpos($data, "$dir/foobar/testdata2.txt") === false, 'Path not in TAR'); + $this->assertTrue(strpos($data, "foobar") === false, 'Path not in TAR'); + + @unlink($tmp); + } + + /** + * List the contents of the prebuilt TAR files + */ + public function test_tarcontent(){ + $dir = dirname(__FILE__).'/tar'; + + foreach(array('tar','tgz','tbz') as $ext){ + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $content = $tar->contents(); + + $this->assertCount(4, $content, "Contents of $file"); + $this->assertEquals('tar/testdata1.txt', $content[1]['filename'], "Contents of $file"); + $this->assertEquals(13, $content[1]['size'], "Contents of $file"); + + $this->assertEquals('tar/foobar/testdata2.txt', $content[3]['filename'], "Contents of $file"); + $this->assertEquals(13, $content[1]['size'], "Contents of $file"); + } + } + + /** + * Extract the prebuilt tar files + */ + public function test_tarextract(){ + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + foreach(array('tar', 'tgz', 'tbz') as $ext){ + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $tar->extract($out); + + clearstatcache(); + + $this->assertFileExists($out.'/tar/testdata1.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/tar/testdata1.txt'), "Extracted $file"); + + $this->assertFileExists($out.'/tar/foobar/testdata2.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/tar/foobar/testdata2.txt'), "Extracted $file"); + + TestUtils::rdelete($out); + } + + } + + /** + * Check the extension to compression guesser + */ + public function test_filetype(){ + $tar = new Tar(); + $this->assertEquals(Tar::COMPRESS_NONE, $tar->filetype('foo')); + $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tgz')); + $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tGZ')); + $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tar.GZ')); + $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tar.gz')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tbz')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tBZ')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.BZ2')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); + } +} \ No newline at end of file -- cgit v1.2.3 From 7252880f21c842017c334eb15c6a7a174f950798 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 3 Nov 2012 18:30:52 +0100 Subject: added test cases for Tar::extract parameters --- _test/tests/inc/tar.test.php | 103 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) (limited to '_test/tests/inc/tar.test.php') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 706516d9e..4de9e668d 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -113,9 +113,112 @@ class Tar_TestCase extends DokuWikiTest { TestUtils::rdelete($out); } + } + + /** + * Extract the prebuilt tar files with component stripping + */ + public function test_compstripextract(){ + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + foreach(array('tar', 'tgz', 'tbz') as $ext){ + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $tar->extract($out,1); + + clearstatcache(); + + $this->assertFileExists($out.'/testdata1.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/testdata1.txt'), "Extracted $file"); + + $this->assertFileExists($out.'/foobar/testdata2.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/foobar/testdata2.txt'), "Extracted $file"); + + TestUtils::rdelete($out); + } + } + + /** + * Extract the prebuilt tar files with prefix stripping + */ + public function test_prefixstripextract(){ + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + foreach(array('tar', 'tgz', 'tbz') as $ext){ + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $tar->extract($out,'tar/foobar/'); + + clearstatcache(); + + $this->assertFileExists($out.'/tar/testdata1.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/tar/testdata1.txt'), "Extracted $file"); + + $this->assertFileExists($out.'/testdata2.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/testdata2.txt'), "Extracted $file"); + + TestUtils::rdelete($out); + } } + /** + * Extract the prebuilt tar files with include regex + */ + public function test_includeextract(){ + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + foreach(array('tar', 'tgz', 'tbz') as $ext){ + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $tar->extract($out,'','','/\/foobar\//'); + + clearstatcache(); + + $this->assertFileNotExists($out.'/tar/testdata1.txt', "Extracted $file"); + + + $this->assertFileExists($out.'/tar/foobar/testdata2.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/tar/foobar/testdata2.txt'), "Extracted $file"); + + TestUtils::rdelete($out); + } + } + + /** + * Extract the prebuilt tar files with exclude regex + */ + public function test_excludeextract(){ + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + foreach(array('tar', 'tgz', 'tbz') as $ext){ + $tar = new Tar(); + $file = "$dir/test.$ext"; + + $tar->open($file); + $tar->extract($out,'','/\/foobar\//'); + + clearstatcache(); + + $this->assertFileExists($out.'/tar/testdata1.txt', "Extracted $file"); + $this->assertEquals(13, filesize($out.'/tar/testdata1.txt'), "Extracted $file"); + + $this->assertFileNotExists($out.'/tar/foobar/testdata2.txt', "Extracted $file"); + + TestUtils::rdelete($out); + } + } + + /** * Check the extension to compression guesser */ -- cgit v1.2.3 From 421a2704022cbc8fa07ab673c2d503199f460b8e Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 4 Nov 2012 10:36:58 +0100 Subject: Tar: Added extraction support for long file names Supports POSIX ustar prefixes and GNU longlink entries --- _test/tests/inc/tar.test.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to '_test/tests/inc/tar.test.php') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 4de9e668d..9abd27612 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -218,7 +218,6 @@ class Tar_TestCase extends DokuWikiTest { } } - /** * Check the extension to compression guesser */ @@ -234,4 +233,20 @@ class Tar_TestCase extends DokuWikiTest { $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.BZ2')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); } + + public function test_longpathextract(){ + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + foreach(array('ustar','gnu') as $format){ + $tar = new Tar(); + $tar->open("$dir/longpath-$format.tgz"); + $tar->extract($out); + + $this->assertFileExists($out.'/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/1234567890/test.txt'); + + TestUtils::rdelete($out); + } + } + } \ No newline at end of file -- cgit v1.2.3 From 90a1db709d3590e849a5a4966fbdf8fb58ae75cd Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 4 Nov 2012 11:31:20 +0100 Subject: Tar: support for creating archives with long filenames The library now creates either a POSIX ustar prefix or a GNU longlink entry for files which have a name longer than 100 bytes --- _test/tests/inc/tar.test.php | 97 +++++++++++++++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 24 deletions(-) (limited to '_test/tests/inc/tar.test.php') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 9abd27612..47851fd4c 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -8,7 +8,7 @@ class Tar_TestCase extends DokuWikiTest { * * No check for format correctness */ - public function test_createdynamic(){ + public function test_createdynamic() { $tar = new Tar(); $dir = dirname(__FILE__).'/tar'; @@ -38,7 +38,7 @@ class Tar_TestCase extends DokuWikiTest { * * No check for format correctness */ - public function test_createfile(){ + public function test_createfile() { $tar = new Tar(); $dir = dirname(__FILE__).'/tar'; @@ -70,10 +70,10 @@ class Tar_TestCase extends DokuWikiTest { /** * List the contents of the prebuilt TAR files */ - public function test_tarcontent(){ + public function test_tarcontent() { $dir = dirname(__FILE__).'/tar'; - foreach(array('tar','tgz','tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -92,11 +92,11 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files */ - public function test_tarextract(){ + public function test_tarextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -118,16 +118,16 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with component stripping */ - public function test_compstripextract(){ + public function test_compstripextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; $tar->open($file); - $tar->extract($out,1); + $tar->extract($out, 1); clearstatcache(); @@ -144,16 +144,16 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with prefix stripping */ - public function test_prefixstripextract(){ + public function test_prefixstripextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; $tar->open($file); - $tar->extract($out,'tar/foobar/'); + $tar->extract($out, 'tar/foobar/'); clearstatcache(); @@ -170,22 +170,21 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with include regex */ - public function test_includeextract(){ + public function test_includeextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; $tar->open($file); - $tar->extract($out,'','','/\/foobar\//'); + $tar->extract($out, '', '', '/\/foobar\//'); clearstatcache(); $this->assertFileNotExists($out.'/tar/testdata1.txt', "Extracted $file"); - $this->assertFileExists($out.'/tar/foobar/testdata2.txt', "Extracted $file"); $this->assertEquals(13, filesize($out.'/tar/foobar/testdata2.txt'), "Extracted $file"); @@ -196,16 +195,16 @@ class Tar_TestCase extends DokuWikiTest { /** * Extract the prebuilt tar files with exclude regex */ - public function test_excludeextract(){ + public function test_excludeextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext){ + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; $tar->open($file); - $tar->extract($out,'','/\/foobar\//'); + $tar->extract($out, '', '/\/foobar\//'); clearstatcache(); @@ -221,8 +220,8 @@ class Tar_TestCase extends DokuWikiTest { /** * Check the extension to compression guesser */ - public function test_filetype(){ - $tar = new Tar(); + public function test_filetype() { + $tar = new Tar(); $this->assertEquals(Tar::COMPRESS_NONE, $tar->filetype('foo')); $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tgz')); $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tGZ')); @@ -234,12 +233,12 @@ class Tar_TestCase extends DokuWikiTest { $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); } - public function test_longpathextract(){ + public function test_longpathextract() { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('ustar','gnu') as $format){ - $tar = new Tar(); + foreach(array('ustar', 'gnu') as $format) { + $tar = new Tar(); $tar->open("$dir/longpath-$format.tgz"); $tar->extract($out); @@ -249,4 +248,54 @@ class Tar_TestCase extends DokuWikiTest { } } + public function test_createlongpathustar() { + $tar = new Tar(); + $tmp = tempnam(sys_get_temp_dir(), 'dwtartest'); + + $path = ''; + for($i=0; $i<11; $i++) $path .= '1234567890/'; + $path = rtrim($path,'/'); + + $tar->create($tmp, Tar::COMPRESS_NONE); + $tar->addData("$path/test.txt", 'testcontent1'); + $tar->close(); + + $this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number + $data = file_get_contents($tmp); + + // We should find the path and filename separated, no longlink entry + $this->assertTrue(strpos($data, 'testcontent1') !== false, 'content in TAR'); + $this->assertTrue(strpos($data, 'test.txt') !== false, 'filename in TAR'); + $this->assertTrue(strpos($data, $path) !== false, 'path in TAR'); + $this->assertFalse(strpos($data, "$path/test.txt") !== false, 'full filename in TAR'); + $this->assertFalse(strpos($data, '@LongLink') !== false, '@LongLink in TAR'); + + @unlink($tmp); + } + + public function test_createlongpathgnu() { + $tar = new Tar(); + $tmp = tempnam(sys_get_temp_dir(), 'dwtartest'); + + $path = ''; + for($i=0; $i<20; $i++) $path .= '1234567890/'; + $path = rtrim($path,'/'); + + $tar->create($tmp, Tar::COMPRESS_NONE); + $tar->addData("$path/test.txt", 'testcontent1'); + $tar->close(); + + $this->assertTrue(filesize($tmp) > 30); //arbitrary non-zero number + $data = file_get_contents($tmp); + + // We should find the complete path/filename and a longlink entry + $this->assertTrue(strpos($data, 'testcontent1') !== false, 'content in TAR'); + $this->assertTrue(strpos($data, 'test.txt') !== false, 'filename in TAR'); + $this->assertTrue(strpos($data, $path) !== false, 'path in TAR'); + $this->assertTrue(strpos($data, "$path/test.txt") !== false, 'full filename in TAR'); + $this->assertTrue(strpos($data, '@LongLink') !== false, '@LongLink in TAR'); + + @unlink($tmp); + } + } \ No newline at end of file -- cgit v1.2.3 From 2949ece61602372cf55fba6be4522fa8899fb70d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 4 Nov 2012 12:21:47 +0100 Subject: unit test for tar bombs --- _test/tests/inc/tar.test.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to '_test/tests/inc/tar.test.php') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index 47851fd4c..e8805a75d 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -298,4 +298,22 @@ class Tar_TestCase extends DokuWikiTest { @unlink($tmp); } + /** + * Extract a tarbomomb + */ + public function test_tarbomb() { + $dir = dirname(__FILE__).'/tar'; + $out = sys_get_temp_dir().'/dwtartest'.md5(time()); + + $tar = new Tar(); + + $tar->open("$dir/tarbomb.tgz"); + $tar->extract($out); + + clearstatcache(); + + $this->assertFileExists($out.'/AAAAAAAAAAAAAAAAA/BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB.txt'); + + TestUtils::rdelete($out); + } } \ No newline at end of file -- cgit v1.2.3 From f2cb3ec76dec3fe2b40f25765ef842223c7132fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 23 Jan 2013 13:55:25 +0200 Subject: handle bzip1 as well in fact .tbz is tar.bz (bzip1) and .tbz2 is what tar.bz2 is used commonly. --- _test/tests/inc/tar.test.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to '_test/tests/inc/tar.test.php') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index e8805a75d..f27b9506b 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -73,7 +73,7 @@ class Tar_TestCase extends DokuWikiTest { public function test_tarcontent() { $dir = dirname(__FILE__).'/tar'; - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -96,7 +96,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -122,7 +122,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -148,7 +148,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -174,7 +174,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -199,7 +199,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -229,6 +229,10 @@ class Tar_TestCase extends DokuWikiTest { $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tar.gz')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tbz')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tBZ')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tbz2')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tBZ2')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.BZ')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.BZ2')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); } @@ -316,4 +320,4 @@ class Tar_TestCase extends DokuWikiTest { TestUtils::rdelete($out); } -} \ No newline at end of file +} -- cgit v1.2.3 From 7afccd0aab62eed3797273e5241b7729bab1fb3f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 23 Jan 2013 16:16:18 +0100 Subject: Revert "handle bzip1 as well" This reverts commit f2cb3ec76dec3fe2b40f25765ef842223c7132fe. Turns out I was too fast merging this. I can't get PHP's bzip handler to handle a bzip1 compressed file. --- _test/tests/inc/tar.test.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to '_test/tests/inc/tar.test.php') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index f27b9506b..e8805a75d 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -73,7 +73,7 @@ class Tar_TestCase extends DokuWikiTest { public function test_tarcontent() { $dir = dirname(__FILE__).'/tar'; - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -96,7 +96,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -122,7 +122,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -148,7 +148,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -174,7 +174,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -199,7 +199,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -229,10 +229,6 @@ class Tar_TestCase extends DokuWikiTest { $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tar.gz')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tbz')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tBZ')); - $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tbz2')); - $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tBZ2')); - $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz')); - $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.BZ')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.BZ2')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); } @@ -320,4 +316,4 @@ class Tar_TestCase extends DokuWikiTest { TestUtils::rdelete($out); } -} +} \ No newline at end of file -- cgit v1.2.3