]> granicus.if.org Git - php/commitdiff
Fixed a bug in the filter extension that prevented magic_quotes_gpc from
authorIlia Alshanetsky <iliaa@php.net>
Thu, 27 Jul 2006 18:14:55 +0000 (18:14 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 27 Jul 2006 18:14:55 +0000 (18:14 +0000)
being applied when RAW filter is used.

NEWS
ext/filter/filter.c

diff --git a/NEWS b/NEWS
index 0072dfc510aec28765f8dcb3c14af7a76e4eb4a8..db286a189e1d88bdc5fabaa93ad87b8ca002b628 100644 (file)
--- 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)
index 05bdfc6a8e52fd690090d225d1cd83023a2c0952..1d0c57cbf33a85bd3d4e5b608b70fe3006f594b6 100644 (file)
@@ -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) {