]> granicus.if.org Git - php/commitdiff
Deprecate FILTER_SANITIZE_MAGIC_QUOTES
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 12 Jul 2019 08:21:21 +0000 (10:21 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 22 Jul 2019 09:39:52 +0000 (11:39 +0200)
ext/filter/filter.c
ext/filter/php_filter.h
ext/filter/sanitizing_filters.c
ext/filter/tests/020.phpt
ext/filter/tests/033.phpt
ext/filter/tests/059.phpt

index 06467417db25dd3f29c4a90dcbc0a99afa8225f4..e615edf08480580233929fe2fb2b02f3c0b02cdf 100644 (file)
@@ -58,7 +58,7 @@ static const filter_list_entry filter_list[] = {
        { "url",             FILTER_SANITIZE_URL,           php_filter_url             },
        { "number_int",      FILTER_SANITIZE_NUMBER_INT,    php_filter_number_int      },
        { "number_float",    FILTER_SANITIZE_NUMBER_FLOAT,  php_filter_number_float    },
-       { "magic_quotes",    FILTER_SANITIZE_MAGIC_QUOTES,  php_filter_add_slashes     },
+       { "magic_quotes",    FILTER_SANITIZE_MAGIC_QUOTES,  php_filter_magic_quotes    },
        { "add_slashes",     FILTER_SANITIZE_ADD_SLASHES,   php_filter_add_slashes     },
 
        { "callback",        FILTER_CALLBACK,               php_filter_callback        },
index 48c08882d3a19243af171a129a85d4b1af014670..24b177d275bd7f0576ddcfe5b9d57cdaac6ea534 100644 (file)
@@ -92,6 +92,7 @@ void php_filter_url(PHP_INPUT_FILTER_PARAM_DECL);
 void php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL);
 void php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL);
 void php_filter_add_slashes(PHP_INPUT_FILTER_PARAM_DECL);
+void php_filter_magic_quotes(PHP_INPUT_FILTER_PARAM_DECL);
 
 void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL);
 
index 815ba9a94acae951f79c8ba44c6e4d2117abad93..5b4fb4432cd89c9fe7194e1e7f002cc04c59851b 100644 (file)
@@ -369,11 +369,20 @@ void php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL)
 /* {{{ php_filter_add_slashes */
 void php_filter_add_slashes(PHP_INPUT_FILTER_PARAM_DECL)
 {
-       /* This filter is used by both 'add_slashes' & 'magic_quotes' (legacy) */
+       zend_string *buf = php_addslashes(Z_STR_P(value));
 
+       zval_ptr_dtor(value);
+       ZVAL_STR(value, buf);
+}
+/* }}} */
+
+/* {{{ php_filter_magic_quotes */
+void php_filter_magic_quotes(PHP_INPUT_FILTER_PARAM_DECL)
+{
        zend_string *buf;
+       php_error_docref(NULL, E_DEPRECATED,
+               "FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead");
 
-       /* just call php_addslashes quotes */
        buf = php_addslashes(Z_STR_P(value));
 
        zval_ptr_dtor(value);
index 855897da9bdb1e48afa058182fd0192263ce2651..5c2ec5bfb277395be222aec2661b4a77bb26aee0 100644 (file)
@@ -12,9 +12,16 @@ var_dump(filter_var(-1, FILTER_SANITIZE_MAGIC_QUOTES));
 
 echo "Done\n";
 ?>
---EXPECT--
+--EXPECTF--
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
 string(36) "test\'asd\'asd\'\' asd\\\'\"asdfasdf"
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
 string(2) "\'"
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
 string(0) ""
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
 string(2) "-1"
 Done
index affb878dbbadbfe4ee03d1db03ce2c6821ee389e..83ae4a3c19f082715bce7f40c3bb060e5ea8dac9 100644 (file)
@@ -9,7 +9,7 @@ default_charset=UTF-8
 <?php
 include __DIR__ . '/033_run.inc';
 ?>
---EXPECT--
+--EXPECTF--
 int                      1                                               123                                                         
 boolean                  1                                                                                                           
 float                    1                                               123                                                         
@@ -29,6 +29,26 @@ email               PHP  1  foo@bar.com    httpa.b.c           1.2.3.4   123  12
 url                 PHP  1  foo@bar.com    http://a.b.c        1.2.3.4   123  123abc<>()          O'Henry                  aa:bb:cc:dd:ee:ff
 number_int               1                                     1234      123  123                                                    
 number_float             1                                     1234      123  123                                                    
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
+
+Deprecated: filter_var(): FILTER_SANITIZE_MAGIC_QUOTES is deprecated, use FILTER_SANITIZE_ADD_SLASHES instead in %s on line %d
 magic_quotes        PHP  1  foo@bar.com    http://a.b.c        1.2.3.4   123  123abc<>()          O\'Henry       하퍼    aa:bb:cc:dd:ee:ff
 add_slashes         PHP  1  foo@bar.com    http://a.b.c        1.2.3.4   123  123abc<>()          O\'Henry       하퍼    aa:bb:cc:dd:ee:ff
 callback            PHP  1  FOO@BAR.COM    HTTP://A.B.C        1.2.3.4   123  123ABC<>()          O'HENRY        하퍼    AA:BB:CC:DD:EE:FF
index 87729880acb02b76f9ee9dd7779958957c5c8421..f1d24353a021946ed09016ee8b24fc302085adb0 100644 (file)
@@ -5,20 +5,11 @@ filter_var() and FILTER_SANITIZE_ADD_SLASHES
 --FILE--
 <?php
 
-function filter_test_compare($input) {
-    return filter_var($input, FILTER_SANITIZE_ADD_SLASHES) === filter_var($input, FILTER_SANITIZE_MAGIC_QUOTES);
-}
-
 var_dump(filter_var("test'asd'asd'' asd\'\"asdfasdf", FILTER_SANITIZE_ADD_SLASHES));
 var_dump(filter_var("'", FILTER_SANITIZE_ADD_SLASHES));
 var_dump(filter_var("", FILTER_SANITIZE_ADD_SLASHES));
 var_dump(filter_var(-1, FILTER_SANITIZE_ADD_SLASHES));
 
-var_dump(filter_test_compare("test'asd'asd'' asd\'\"asdfasdf"));
-var_dump(filter_test_compare("''"));
-var_dump(filter_test_compare(''));
-var_dump(filter_test_compare(-1));
-
 echo "Done\n";
 ?>
 --EXPECT--
@@ -26,8 +17,4 @@ string(36) "test\'asd\'asd\'\' asd\\\'\"asdfasdf"
 string(2) "\'"
 string(0) ""
 string(2) "-1"
-bool(true)
-bool(true)
-bool(true)
-bool(true)
 Done