From 7df24bb758540ca7c905bba394a160ef6ccccc64 Mon Sep 17 00:00:00 2001 From: jer Date: Tue, 11 Feb 2014 15:13:36 +0100 Subject: [PATCH 1/2] added PHP 5.4 support for strings in Bz2 and Gz decompress --- library/Zend/Filter/Compress/Bz2.php | 4 +++- library/Zend/Filter/Compress/Gz.php | 4 +++- tests/ZendTest/Filter/Compress/Bz2Test.php | 4 ---- tests/ZendTest/Filter/Compress/GzTest.php | 4 ---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/library/Zend/Filter/Compress/Bz2.php b/library/Zend/Filter/Compress/Bz2.php index 1e37109a20a..79716118b30 100644 --- a/library/Zend/Filter/Compress/Bz2.php +++ b/library/Zend/Filter/Compress/Bz2.php @@ -133,7 +133,9 @@ public function compress($content) public function decompress($content) { $archive = $this->getArchive(); - if (file_exists($content)) { + + //check if there are null byte characters before doing a file_exists check + if (!strstr($content, "\0") && file_exists($content)) { $archive = $content; } diff --git a/library/Zend/Filter/Compress/Gz.php b/library/Zend/Filter/Compress/Gz.php index cb1c47dc308..57d05dfdf1c 100644 --- a/library/Zend/Filter/Compress/Gz.php +++ b/library/Zend/Filter/Compress/Gz.php @@ -165,7 +165,9 @@ public function decompress($content) { $archive = $this->getArchive(); $mode = $this->getMode(); - if (file_exists($content)) { + + //check if there are null byte characters before doing a file_exists check + if (!strstr($content, "\0") && file_exists($content)) { $archive = $content; } diff --git a/tests/ZendTest/Filter/Compress/Bz2Test.php b/tests/ZendTest/Filter/Compress/Bz2Test.php index 0b62f2328be..645a9099001 100644 --- a/tests/ZendTest/Filter/Compress/Bz2Test.php +++ b/tests/ZendTest/Filter/Compress/Bz2Test.php @@ -37,10 +37,6 @@ public function tearDown() */ public function testBasicUsage() { - if (version_compare(phpversion(), '5.4', '>=')) { - $this->markTestIncomplete('Code to test is not compatible with PHP 5.4 '); - } - $filter = new Bz2Compression(); $content = $filter->compress('compress me'); diff --git a/tests/ZendTest/Filter/Compress/GzTest.php b/tests/ZendTest/Filter/Compress/GzTest.php index 51d9602d262..dbaba61612e 100644 --- a/tests/ZendTest/Filter/Compress/GzTest.php +++ b/tests/ZendTest/Filter/Compress/GzTest.php @@ -37,10 +37,6 @@ public function tearDown() */ public function testBasicUsage() { - if (version_compare(phpversion(), '5.4', '>=')) { - $this->markTestIncomplete('Code to test is not compatible with PHP 5.4 '); - } - $filter = new GzCompression(); $content = $filter->compress('compress me'); From 413ed9fb83a53aa055f95661fcb803e89891632a Mon Sep 17 00:00:00 2001 From: jer Date: Tue, 11 Feb 2014 16:24:03 +0100 Subject: [PATCH 2/2] PHP 5.4 support for strings in Bz2 and Gz decompress - removed PHP 5.4 version check for some tests --- tests/ZendTest/Filter/Compress/GzTest.php | 4 ---- tests/ZendTest/Filter/CompressTest.php | 4 ---- tests/ZendTest/Filter/DecompressTest.php | 4 ---- tests/ZendTest/Filter/Encrypt/BlockCipherTest.php | 4 ---- tests/ZendTest/Filter/Encrypt/OpensslTest.php | 4 ---- 5 files changed, 20 deletions(-) diff --git a/tests/ZendTest/Filter/Compress/GzTest.php b/tests/ZendTest/Filter/Compress/GzTest.php index dbaba61612e..1f901bca871 100644 --- a/tests/ZendTest/Filter/Compress/GzTest.php +++ b/tests/ZendTest/Filter/Compress/GzTest.php @@ -160,10 +160,6 @@ public function testGzCompressToFile() */ public function testGzDeflate() { - if (version_compare(phpversion(), '5.4', '>=')) { - $this->markTestIncomplete('Code to test is not compatible with PHP 5.4 '); - } - $filter = new GzCompression(array('mode' => 'deflate')); $content = $filter->compress('compress me'); diff --git a/tests/ZendTest/Filter/CompressTest.php b/tests/ZendTest/Filter/CompressTest.php index fbcd47c1563..2aed886d094 100644 --- a/tests/ZendTest/Filter/CompressTest.php +++ b/tests/ZendTest/Filter/CompressTest.php @@ -37,10 +37,6 @@ public function tearDown() */ public function testBasicUsage() { - if (version_compare(phpversion(), '5.4', '>=')) { - $this->markTestIncomplete('Code to test is not compatible with PHP 5.4 '); - } - $filter = new CompressFilter('bz2'); $text = 'compress me'; diff --git a/tests/ZendTest/Filter/DecompressTest.php b/tests/ZendTest/Filter/DecompressTest.php index cc46b531ff5..b6e94752bda 100644 --- a/tests/ZendTest/Filter/DecompressTest.php +++ b/tests/ZendTest/Filter/DecompressTest.php @@ -37,10 +37,6 @@ public function tearDown() */ public function testBasicUsage() { - if (version_compare(phpversion(), '5.4', '>=')) { - $this->markTestIncomplete('Code to test is not compatible with PHP 5.4 '); - } - $filter = new DecompressFilter('bz2'); $text = 'compress me'; diff --git a/tests/ZendTest/Filter/Encrypt/BlockCipherTest.php b/tests/ZendTest/Filter/Encrypt/BlockCipherTest.php index 2273cfbe726..53759f2cebd 100644 --- a/tests/ZendTest/Filter/Encrypt/BlockCipherTest.php +++ b/tests/ZendTest/Filter/Encrypt/BlockCipherTest.php @@ -200,10 +200,6 @@ public function testSettingEmptyVector() */ public function testEncryptionWithDecryptionAndCompressionMcrypt() { - if (version_compare(phpversion(), '5.4', '>=')) { - $this->markTestIncomplete('Code to test is not compatible with PHP 5.4 '); - } - if (!extension_loaded('bz2')) { $this->markTestSkipped('This adapter needs the bz2 extension'); } diff --git a/tests/ZendTest/Filter/Encrypt/OpensslTest.php b/tests/ZendTest/Filter/Encrypt/OpensslTest.php index 972946ed2c4..e7f214c3564 100644 --- a/tests/ZendTest/Filter/Encrypt/OpensslTest.php +++ b/tests/ZendTest/Filter/Encrypt/OpensslTest.php @@ -274,10 +274,6 @@ public function testEncryptionWithDecryptionWithPackagedKeys() */ public function testEncryptionWithDecryptionAndCompressionWithPackagedKeys() { - if (version_compare(phpversion(), '5.4', '>=')) { - $this->markTestIncomplete('Code to test is not compatible with PHP 5.4 '); - } - if (!extension_loaded('bz2')) { $this->markTestSkipped('Bz2 extension for compression test needed'); }