From: Ilia Alshanetsky Date: Thu, 27 Jul 2006 18:14:55 +0000 (+0000) Subject: Fixed a bug in the filter extension that prevented magic_quotes_gpc from X-Git-Tag: php-5.2.0RC2~172 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c2d752fb1629acdcda82e75956f6637091e3b71;p=php Fixed a bug in the filter extension that prevented magic_quotes_gpc from being applied when RAW filter is used. --- diff --git a/NEWS b/NEWS index 0072dfc510..db286a189e 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ PHP NEWS . Fixed bug #37564 (AES privacy encryption not possible due to net-snmp 5.2 compatibility issue). (Patch: scott dot moynes+php at gmail dot com) +- Fixed a bug in the filter extension that prevented magic_quotes_gpc from + being applied when RAW filter is used. (Ilia) - Fixed bug #38236 (Binary data gets corrupted on multipart/formdata POST). (Ilia) - Fixed bug #38234 (Exception in __clone makes memory leak). (Dmitry, Nuno) diff --git a/ext/filter/filter.c b/ext/filter/filter.c index 05bdfc6a8e..1d0c57cbf3 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -368,17 +368,23 @@ static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int php_register_variable_ex(var, &raw_var, array_ptr TSRMLS_CC); } - /* Register mangled variable */ - /* FIXME: Should not use php_register_variable_ex as that also registers - * globals when register_globals is turned on */ - Z_STRLEN(new_var) = val_len; - Z_STRVAL(new_var) = estrndup(*val, val_len + 1); - Z_TYPE(new_var) = IS_STRING; - if (val_len) { - if (! (IF_G(default_filter) == FILTER_UNSAFE_RAW)) { + /* Register mangled variable */ + /* FIXME: Should not use php_register_variable_ex as that also registers + * globals when register_globals is turned on */ + Z_STRLEN(new_var) = val_len; + Z_TYPE(new_var) = IS_STRING; + + if (!(IF_G(default_filter) == FILTER_UNSAFE_RAW)) { + Z_STRVAL(new_var) = estrndup(*val, val_len + 1); php_zval_filter(&new_var, IF_G(default_filter), IF_G(default_filter_flags), NULL, NULL/*charset*/ TSRMLS_CC); + } else if (PG(magic_quotes_gpc)) { + Z_STRVAL(new_var) = php_addslashes(*val, Z_STRLEN(new_var), &Z_STRLEN(new_var), 0 TSRMLS_CC); + } else { + Z_STRVAL(new_var) = estrndup(*val, val_len + 1); } + } else { /* empty string */ + ZVAL_EMPTY_STRING(&new_var); } if (orig_array_ptr) {