mirror of
https://github.com/php/php-src.git
synced 2024-11-29 04:46:07 +08:00
- Fixed zlib.deflate compress filter to actually accpet level parameter.
This commit is contained in:
parent
b964306fd7
commit
6bb0603c4f
1
NEWS
1
NEWS
@ -16,6 +16,7 @@ PHP NEWS
|
||||
- Improved shared extension loading on OSX to use the standard Unix dlopen()
|
||||
API. (Scott)
|
||||
|
||||
- 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 possible bad caching of symlinked directories in the realpath cache
|
||||
|
16
ext/zlib/tests/zlib_filter_deflate2.phpt
Normal file
16
ext/zlib/tests/zlib_filter_deflate2.phpt
Normal file
@ -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Ñ«ÌÎ<C38C>ñ£†1´MBâíUvñ_‚(ÆELÆõÌ/<2F>•aP¹=Pié;Ò6‰fÅCe4·<34>U9;wˆ5ý±m/
|
@ -352,7 +352,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. */
|
||||
@ -361,8 +361,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);
|
||||
@ -376,8 +374,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);
|
||||
@ -391,6 +387,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;
|
||||
}
|
||||
@ -398,19 +396,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:
|
||||
|
Loading…
Reference in New Issue
Block a user