Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[Zend\Filter\Compress] added PHP 5.4 support for strings in Bz2 and Gz decompress #5839

Merged
merged 2 commits into from

3 participants

@wdJer

With this PR Zend\Filter\Compress\Bz2 and Zend\Filter\Compress\Gz are capable of decompressing Strings in PHP 5.4 without throwing a Warning like stated in #5788
In my research I found out, that the only problem are null byte characters, so we go for a check if there is a null byte char in the given content.
The skipped tests are working now in PHP >= 5.4

@Maks3w Maks3w was assigned
@Maks3w Maks3w merged commit 413ed9f into zendframework:master
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-filter
@Maks3w Maks3w Merge pull request zendframework/zf2#5839. Fix zendframework/zf2#5788 a37f906
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-filter
@Maks3w Maks3w Merge pull request zendframework/zf2#5839. Fix zendframework/zf2#5788
…in develop
6d9fbe4
@gianarb gianarb referenced this pull request from a commit in zendframework/zend-filter
@Maks3w Maks3w Merge pull request zendframework/zf2#5839. Fix zendframework/zf2#5788
…in master
477bd0b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
4 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;
}
View
4 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;
}
View
4 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');
View
8 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');
@@ -164,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');
View
4 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';
View
4 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';
View
4 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');
}
View
4 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');
}
Something went wrong with that request. Please try again.