summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJani Taskinen <jani@php.net>2009-08-31 21:18:55 +0000
committerJani Taskinen <jani@php.net>2009-08-31 21:18:55 +0000
commit532e14245973c7c26f1fb5d06957745d7fb5c4d6 (patch)
treec549673c3281c825c88938da69b6034315f28b4a
parentf03552c27d87cbbcd99e688db67ec8fcd67d3698 (diff)
downloadphp-git-532e14245973c7c26f1fb5d06957745d7fb5c4d6.tar.gz
- Fixed zlib.deflate compress filter to actually accpet level parameter.
-rw-r--r--NEWS1
-rw-r--r--ext/zlib/tests/zlib_filter_deflate2.phpt16
-rw-r--r--ext/zlib/zlib_filter.c29
3 files changed, 29 insertions, 17 deletions
diff --git a/NEWS b/NEWS
index f79275d629..9738de30cc 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP NEWS
?? ??? 2009, PHP 5.2.11
- Added missing sanity checks around exif processing (Ilia)
+- Fixed zlib.deflate compress filter to actually accpet level parameter. (Jani)
- Fixed leak on error in popen/exec (and related functions on Windows. (Pierre)
- Fixed bug #49361 (wordwrap() wraps incorrectly on end of line boundaries).
diff --git a/ext/zlib/tests/zlib_filter_deflate2.phpt b/ext/zlib/tests/zlib_filter_deflate2.phpt
new file mode 100644
index 0000000000..764a7606f4
--- /dev/null
+++ b/ext/zlib/tests/zlib_filter_deflate2.phpt
@@ -0,0 +1,16 @@
+--TEST--
+zlib.deflate (with level parameter set)
+--SKIPIF--
+<?php if (!extension_loaded("zlib")) print "skip"; ?>
+--FILE--
+<?php
+$text = 'I am the very model of a modern major general, I\'ve information vegetable, animal, and mineral.';
+
+$fp = fopen('php://stdout', 'w');
+stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, array('level' => 9));
+fwrite($fp, $text);
+fclose($fp);
+
+?>
+--EXPECT--
+A Dѫ΍1MBUv_(EL/aP=Pi ;6fCe4U9;w5 m /
diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c
index 1e1d6029d4..cd45d2329e 100644
--- a/ext/zlib/zlib_filter.c
+++ b/ext/zlib/zlib_filter.c
@@ -353,7 +353,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
if (filterparams) {
- zval **tmpzval;
+ zval **tmpzval, tmp;
/* filterparams can either be a scalar value to indicate compression level (shortcut method)
Or can be a hash containing one or more of 'window', 'memory', and/or 'level' members. */
@@ -362,8 +362,6 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
case IS_ARRAY:
case IS_OBJECT:
if (zend_hash_find(HASH_OF(filterparams), "memory", sizeof("memory"), (void**) &tmpzval) == SUCCESS) {
- zval tmp;
-
tmp = **tmpzval;
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
@@ -377,8 +375,6 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
}
if (zend_hash_find(HASH_OF(filterparams), "window", sizeof("window"), (void**) &tmpzval) == SUCCESS) {
- zval tmp;
-
tmp = **tmpzval;
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
@@ -392,6 +388,8 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
}
if (zend_hash_find(HASH_OF(filterparams), "level", sizeof("level"), (void**) &tmpzval) == SUCCESS) {
+ tmp = **tmpzval;
+
/* Psuedo pass through to catch level validating code */
goto factory_setlevel;
}
@@ -399,19 +397,16 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
case IS_STRING:
case IS_DOUBLE:
case IS_LONG:
- {
- zval tmp;
-
- tmp = *filterparams;
- zval_copy_ctor(&tmp);
- convert_to_long(&tmp);
+ tmp = *filterparams;
factory_setlevel:
- /* Set compression level within reason (-1 == default, 0 == none, 1-9 == least to most compression */
- if (Z_LVAL(tmp) < -1 || Z_LVAL(tmp) > 9) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid compression level specified. (%ld)", Z_LVAL(tmp));
- } else {
- level = Z_LVAL(tmp);
- }
+ zval_copy_ctor(&tmp);
+ convert_to_long(&tmp);
+
+ /* Set compression level within reason (-1 == default, 0 == none, 1-9 == least to most compression */
+ if (Z_LVAL(tmp) < -1 || Z_LVAL(tmp) > 9) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid compression level specified. (%ld)", Z_LVAL(tmp));
+ } else {
+ level = Z_LVAL(tmp);
}
break;
default: