Skip to content
Browse files

This commit was manufactured by cvs2svn to create tag 'RELEASE_1_0_4'.

  • Loading branch information...
1 parent 79bebd9 commit 80b7d0980fea8f46a782a1dd75da7af43ba2596f SVN Migration committed Jan 18, 2006
Showing with 0 additions and 2,993 deletions.
  1. +0 −2 ext/filter/CREDITS
  2. +0 −68 ext/filter/callback_filter.c
  3. +0 −95 ext/filter/config.m4
  4. +0 −8 ext/filter/config.w32
  5. +0 −680 ext/filter/filter.c
  6. +0 −87 ext/filter/filter_private.h
  7. +0 −53 ext/filter/package.xml
  8. +0 −68 ext/filter/package2.xml
  9. +0 −105 ext/filter/php_filter.h
  10. +0 −340 ext/filter/sanitizing_filters.c
  11. +0 −8 ext/filter/tests/001.phpt
  12. +0 −11 ext/filter/tests/002.phpt
  13. +0 −22 ext/filter/tests/003.phpt
  14. +0 −24 ext/filter/tests/004.phpt
  15. +0 −21 ext/filter/tests/005.phpt
  16. +0 −10 ext/filter/tests/006.phpt
  17. +0 −68 ext/filter/tests/007.phpt
  18. +0 −88 ext/filter/tests/008.phpt
  19. +0 −30 ext/filter/tests/009.phpt
  20. +0 −60 ext/filter/tests/010.phpt
  21. +0 −49 ext/filter/tests/011.phpt
  22. +0 −16 ext/filter/tests/012.phpt
  23. +0 −40 ext/filter/tests/013.phpt
  24. +0 −41 ext/filter/tests/014.phpt
  25. +0 −72 ext/filter/tests/015.phpt
  26. +0 −32 ext/filter/tests/016.phpt
  27. +0 −24 ext/filter/tests/017.phpt
  28. +0 −50 ext/filter/tests/018.phpt
  29. +0 −20 ext/filter/tests/019.phpt
  30. +0 −18 ext/filter/tests/020.phpt
  31. +0 −44 ext/filter/tests/021.phpt
  32. +0 −20 ext/filter/tests/022.phpt
  33. +0 −20 ext/filter/tests/023.phpt
  34. +0 −18 ext/filter/tests/024.phpt
  35. +0 −24 ext/filter/tests/025.phpt
  36. +0 −30 ext/filter/tests/026.phpt
  37. +0 −30 ext/filter/tests/027.phpt
  38. +0 −35 ext/filter/tests/028.phpt
  39. +0 −103 ext/filter/tests/029.phpt
  40. +0 −71 ext/filter/tests/filter_data.phpt
  41. +0 −103 ext/imap/imap.h
  42. +0 −285 main/php_realpath.c
View
2 ext/filter/CREDITS
@@ -1,2 +0,0 @@
-Input Filter
-Rasmus Lerdorf, Derick Rethans
View
68 ext/filter/callback_filter.c
@@ -1,68 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Derick Rethans <derick@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php_filter.h"
-
-void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL)
-{
- char *name = NULL;
- zval *retval_ptr;
- zval ***args;
- int status;
-
- if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_CHECK_NO_ACCESS, &name)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument is expected to be a valid callback");
- if (name) {
- efree(name);
- }
- zval_dtor(value);
- Z_TYPE_P(value) = IS_NULL;
- return;
- }
- efree(name);
-
- args = safe_emalloc(sizeof(zval **), 1, 0);
- args[0] = &value;
-
- status = call_user_function_ex(EG(function_table), NULL, option_array, &retval_ptr, 1, args, 0, NULL TSRMLS_CC);
-
- if (status == SUCCESS && retval_ptr != NULL) {
- zval_dtor(value);
- *value = *retval_ptr;
- zval_copy_ctor(value);
- } else {
- zval_dtor(value);
- Z_TYPE_P(value) = IS_NULL;
- }
-
- if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
- }
- efree(args);
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
View
95 ext/filter/config.m4
@@ -1,95 +0,0 @@
-dnl $Id$
-dnl config.m4 for input filtering extension
-
-PHP_ARG_ENABLE(filter, whether to enable input filter support,
-[ --disable-filter Disable input filter support], yes)
-
-PHP_ARG_WITH(pcre-dir, pcre install prefix,
-[ --with-pcre-dir FILTER: pcre install prefix], no, no)
-
-if test "$PHP_FILTER" != "no"; then
-
- dnl Check if configure is the PHP core configure
- if test -n "$PHP_VERSION"; then
- dnl This extension can not be build as shared when in PHP core
- ext_shared=no
- else
- dnl This is PECL build, check if bundled PCRE library is used
- old_CPPFLAGS=$CPPFLAGS
- CPPFLAGS=$INCLUDES
- AC_EGREP_CPP(yes,[
-#include <main/php_config.h>
-#if defined(HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
-yes
-#endif
- ],[
- PHP_PCRE_REGEX=yes
- ],[
- AC_EGREP_CPP(yes,[
-#include <main/php_config.h>
-#if defined(HAVE_PCRE) && !defined(COMPILE_DL_PCRE)
-yes
-#endif
- ],[
- PHP_PCRE_REGEX=pecl
- ],[
- PHP_PCRE_REGEX=no
- ])
- ])
- CPPFLAGS=$old_CPPFLAGS
- fi
-
- if test "$PHP_PCRE_REGEX" != "yes"; then
- dnl
- dnl If PCRE extension is enabled we can use the already found paths,
- dnl otherwise we have to detect them here:
- dnl
- if test "$PHP_PCRE_REGEX" = "no" || test "$PHP_PCRE_REGEX" = "pecl"; then
- dnl Set the PCRE search dirs correctly
- case "$PHP_PCRE_DIR" in
- yes|no)
- PCRE_SEARCH_DIR="/usr/local /usr"
- ;;
- *)
- PCRE_SEARCH_DIR="$PHP_PCRE_DIR"
- ;;
- esac
-
- for i in $PCRE_SEARCH_DIR; do
- if test -f $i/include/pcre/pcre.h; then
- PCRE_INCDIR=$i/include/pcre
- break
- elif test -f $i/include/pcre.h; then
- PCRE_INCDIR=$i/include
- break
- elif test -f $i/pcre.h; then
- PCRE_INCDIR=$i
- break
- fi
- done
-
- if test -z "$PCRE_INCDIR"; then
- AC_MSG_ERROR([Could not find pcre.h anywhere under $PCRE_SEARCH_DIR])
- fi
-
- for j in $PCRE_SEARCH_DIR/$PHP_LIBDIR $PCRE_SEARCH_DIR; do
- if test -f $j/libpcre.a || test -f $j/libpcre.$SHLIB_SUFFIX_NAME; then
- PCRE_LIBDIR=$j
- break
- fi
- done
-
- if test -z "$PCRE_LIBDIR" ; then
- AC_MSG_ERROR([Could not find libpcre.(a|$SHLIB_SUFFIX_NAME) anywhere under $PCRE_SEARCH_DIR])
- fi
- fi
-
- PHP_ADD_LIBRARY_WITH_PATH(pcre, $PCRE_LIBDIR, FILTER_SHARED_LIBADD)
- PHP_ADD_INCLUDE($PCRE_INCDIR)
- fi
-
- PHP_NEW_EXTENSION(filter, filter.c sanitizing_filters.c logical_filters.c callback_filter.c, $ext_shared)
- PHP_SUBST(FILTER_SHARED_LIBADD)
-
- PHP_INSTALL_HEADERS([$ext_srcdir/php_filter.h])
-fi
View
8 ext/filter/config.w32
@@ -1,8 +0,0 @@
-// $Id$
-// vim:ft=javascript
-
-ARG_ENABLE("filter", "Filter Support", "yes");
-
-if (PHP_FILTER == "yes") {
- EXTENSION("filter", "filter.c sanitizing_filters.c logical_filters.c callback_filter.c");
-}
View
680 ext/filter/filter.c
@@ -1,680 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- | Derick Rethans <derick@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php_filter.h"
-
-ZEND_DECLARE_MODULE_GLOBALS(filter)
-
-#include "filter_private.h"
-
-typedef struct filter_list_entry {
- char *name;
- int id;
- void (*function)(PHP_INPUT_FILTER_PARAM_DECL);
-} filter_list_entry;
-
-filter_list_entry filter_list[] = {
- { "int", FL_INT, php_filter_int },
- { "boolean", FL_BOOLEAN, php_filter_boolean },
- { "float", FL_FLOAT, php_filter_float },
-
- { "validate_regexp", FL_REGEXP, php_filter_validate_regexp },
- { "validate_url", FL_URL, php_filter_validate_url },
- { "validate_email", FL_EMAIL, php_filter_validate_email },
- { "validate_ip", FL_IP, php_filter_validate_ip },
-
- { "string", FS_STRING, php_filter_string },
- { "stripped", FS_STRING, php_filter_string },
- { "encoded", FS_ENCODED, php_filter_encoded },
- { "special_chars", FS_SPECIAL_CHARS, php_filter_special_chars },
- { "unsafe_raw", FS_UNSAFE_RAW, php_filter_unsafe_raw },
- { "email", FS_EMAIL, php_filter_email },
- { "url", FS_URL, php_filter_url },
- { "number_int", FS_NUMBER_INT, php_filter_number_int },
- { "number_float", FS_NUMBER_FLOAT, php_filter_number_float },
- { "magic_quotes", FS_MAGIC_QUOTES, php_filter_magic_quotes },
-
- { "callback", FC_CALLBACK, php_filter_callback },
-};
-
-#ifndef PARSE_ENV
-#define PARSE_ENV 4
-#endif
-
-#ifndef PARSE_SERVER
-#define PARSE_SERVER 5
-#endif
-
-#ifndef PARSE_SESSION
-#define PARSE_SESSION 6
-#endif
-
-static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC);
-
-/* {{{ filter_functions[]
- */
-zend_function_entry filter_functions[] = {
- PHP_FE(input_get, NULL)
- PHP_FE(input_filters_list, NULL)
- PHP_FE(input_has_variable, NULL)
- PHP_FE(input_name_to_filter, NULL)
- PHP_FE(filter_data, NULL)
- {NULL, NULL, NULL}
-};
-/* }}} */
-
-/* {{{ filter_module_entry
- */
-zend_module_entry filter_module_entry = {
-#if ZEND_MODULE_API_NO >= 20010901
- STANDARD_MODULE_HEADER,
-#endif
- "filter",
- filter_functions,
- PHP_MINIT(filter),
- PHP_MSHUTDOWN(filter),
- NULL,
- PHP_RSHUTDOWN(filter),
- PHP_MINFO(filter),
- "0.9.3",
- STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-#ifdef COMPILE_DL_FILTER
-ZEND_GET_MODULE(filter)
-#endif
-
-/* {{{ UpdateDefaultFilter
- */
-static PHP_INI_MH(UpdateDefaultFilter)
-{
- int i, size = sizeof(filter_list) / sizeof(filter_list_entry);
-
- for (i = 0; i < size; ++i) {
- if ((strcasecmp(new_value, filter_list[i].name) == 0)) {
- IF_G(default_filter) = filter_list[i].id;
- return SUCCESS;
- }
- }
- /* Fallback to "string" filter */
- IF_G(default_filter) = FS_DEFAULT;
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_INI
- */
-static PHP_INI_MH(OnUpdateFlags)
-{
- if (!new_value) {
- IF_G(default_filter_flags) = FILTER_FLAG_NO_ENCODE_QUOTES;
- } else {
- IF_G(default_filter_flags) = atoi(new_value);
- }
- return SUCCESS;
-}
-
-PHP_INI_BEGIN()
- STD_PHP_INI_ENTRY("filter.default", "string", PHP_INI_ALL, UpdateDefaultFilter, default_filter, zend_filter_globals, filter_globals)
- PHP_INI_ENTRY("filter.default_flags", NULL, PHP_INI_ALL, OnUpdateFlags)
-PHP_INI_END()
-/* }}} */
-
-/* {{{ php_filter_init_globals
-*/
-static void php_filter_init_globals(zend_filter_globals *filter_globals)
-{
- filter_globals->post_array = NULL;
- filter_globals->get_array = NULL;
- filter_globals->cookie_array = NULL;
- filter_globals->env_array = NULL;
- filter_globals->server_array = NULL;
- filter_globals->session_array = NULL;
- filter_globals->default_filter = FS_DEFAULT;
-}
-/* }}} */
-
-#define PARSE_REQUEST 99
-
-/* {{{ PHP_MINIT_FUNCTION
- */
-PHP_MINIT_FUNCTION(filter)
-{
- ZEND_INIT_MODULE_GLOBALS(filter, php_filter_init_globals, NULL);
-
- REGISTER_INI_ENTRIES();
-
- REGISTER_LONG_CONSTANT("INPUT_POST", PARSE_POST, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("INPUT_GET", PARSE_GET, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("INPUT_COOKIE", PARSE_COOKIE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("INPUT_ENV", PARSE_ENV, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("INPUT_SERVER", PARSE_SERVER, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("INPUT_SESSION", PARSE_SESSION, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_NONE", FILTER_FLAG_NONE, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FL_INT", FL_INT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FL_BOOLEAN", FL_BOOLEAN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FL_FLOAT", FL_FLOAT, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FL_REGEXP", FL_REGEXP, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FL_URL", FL_URL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FL_EMAIL", FL_EMAIL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FL_IP", FL_IP, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FS_DEFAULT", FS_DEFAULT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FS_STRING", FS_STRING, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FS_STRIPPED", FS_STRING, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FS_ENCODED", FS_ENCODED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FS_SPECIAL_CHARS", FS_SPECIAL_CHARS, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FS_UNSAFE_RAW", FS_UNSAFE_RAW, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FS_EMAIL", FS_EMAIL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FS_URL", FS_URL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FS_NUMBER_INT", FS_NUMBER_INT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FS_NUMBER_FLOAT", FS_NUMBER_FLOAT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FS_MAGIC_QUOTES", FS_MAGIC_QUOTES, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FC_CALLBACK", FC_CALLBACK, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_OCTAL", FILTER_FLAG_ALLOW_OCTAL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_HEX", FILTER_FLAG_ALLOW_HEX, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_STRIP_LOW", FILTER_FLAG_STRIP_LOW, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_STRIP_HIGH", FILTER_FLAG_STRIP_HIGH, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_LOW", FILTER_FLAG_ENCODE_LOW, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_HIGH", FILTER_FLAG_ENCODE_HIGH, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ENCODE_AMP", FILTER_FLAG_ENCODE_AMP, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_ENCODE_QUOTES", FILTER_FLAG_NO_ENCODE_QUOTES, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_EMPTY_STRING_NULL", FILTER_FLAG_EMPTY_STRING_NULL, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_FRACTION", FILTER_FLAG_ALLOW_FRACTION, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_THOUSAND", FILTER_FLAG_ALLOW_THOUSAND, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_ALLOW_SCIENTIFIC", FILTER_FLAG_ALLOW_SCIENTIFIC, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_SCHEME_REQUIRED", FILTER_FLAG_SCHEME_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_HOST_REQUIRED", FILTER_FLAG_HOST_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_PATH_REQUIRED", FILTER_FLAG_PATH_REQUIRED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_QUERY_REQUIRED", FILTER_FLAG_QUERY_REQUIRED, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("FILTER_FLAG_IPV4", FILTER_FLAG_IPV4, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_IPV6", FILTER_FLAG_IPV6, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_RES_RANGE", FILTER_FLAG_NO_RES_RANGE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("FILTER_FLAG_NO_PRIV_RANGE", FILTER_FLAG_NO_PRIV_RANGE, CONST_CS | CONST_PERSISTENT);
-
- sapi_register_input_filter(php_sapi_filter);
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MSHUTDOWN_FUNCTION
- */
-PHP_MSHUTDOWN_FUNCTION(filter)
-{
- UNREGISTER_INI_ENTRIES();
-
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_RSHUTDOWN_FUNCTION
- */
-#define VAR_ARRAY_COPY_DTOR(a) \
- if (IF_G(a)) { \
- zval_ptr_dtor(&IF_G(a)); \
- IF_G(a) = NULL; \
- }
-PHP_RSHUTDOWN_FUNCTION(filter)
-{
- VAR_ARRAY_COPY_DTOR(get_array)
- VAR_ARRAY_COPY_DTOR(post_array)
- VAR_ARRAY_COPY_DTOR(cookie_array)
- VAR_ARRAY_COPY_DTOR(server_array)
- VAR_ARRAY_COPY_DTOR(env_array)
- VAR_ARRAY_COPY_DTOR(session_array)
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MINFO_FUNCTION
- */
-PHP_MINFO_FUNCTION(filter)
-{
- php_info_print_table_start();
- php_info_print_table_row( 2, "Input Validation and Filtering", "enabled" );
- php_info_print_table_row( 2, "Revision", "$Revision$");
- php_info_print_table_end();
-
- DISPLAY_INI_ENTRIES();
-}
-/* }}} */
-
-static filter_list_entry php_find_filter(long id)
-{
- int i, size = sizeof(filter_list) / sizeof(filter_list_entry);
-
- for (i = 0; i < size; ++i) {
- if (filter_list[i].id == id) {
- return filter_list[i];
- }
- }
- /* Fallback to "string" filter */
- for (i = 0; i < size; ++i) {
- if (filter_list[i].id == FS_DEFAULT) {
- return filter_list[i];
- }
- }
- /* To shut up GCC */
- return filter_list[0];
-}
-
-static void php_zval_filter(zval *value, long filter, long flags, zval *options, char* charset TSRMLS_DC)
-{
- filter_list_entry filter_func;
-
- filter_func = php_find_filter(filter);
-
- if (!filter_func.id) {
- /* Find default filter */
- filter_func = php_find_filter(FS_DEFAULT);
- }
-
- /* Here be strings */
- convert_to_string(value);
-
- filter_func.function(value, flags, options, charset TSRMLS_CC);
-}
-
-/* {{{ php_sapi_filter(int arg, char *var, char **val, unsigned int val_len, unsigned *new_val_len)
- */
-static unsigned int php_sapi_filter(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC)
-{
- zval new_var, raw_var;
- zval *array_ptr = NULL, *orig_array_ptr = NULL;
- char *orig_var;
- int retval = 0;
-
- assert(*val != NULL);
-
-#define PARSE_CASE(s,a,t) \
- case s: \
- if (!IF_G(a)) { \
- ALLOC_ZVAL(array_ptr); \
- array_init(array_ptr); \
- INIT_PZVAL(array_ptr); \
- IF_G(a) = array_ptr; \
- } else { \
- array_ptr = IF_G(a); \
- } \
- orig_array_ptr = PG(http_globals)[t]; \
- break;
-
- switch (arg) {
- PARSE_CASE(PARSE_POST, post_array, TRACK_VARS_POST)
- PARSE_CASE(PARSE_GET, get_array, TRACK_VARS_GET)
- PARSE_CASE(PARSE_COOKIE, cookie_array, TRACK_VARS_COOKIE)
- PARSE_CASE(PARSE_SERVER, server_array, TRACK_VARS_SERVER)
- PARSE_CASE(PARSE_ENV, env_array, TRACK_VARS_ENV)
-
- case PARSE_STRING: /* PARSE_STRING is used by parse_str() function */
- retval = 1;
- break;
- }
-
- if (array_ptr) {
- /* Make a copy of the variable name, as php_register_variable_ex seems to
- * modify it */
- orig_var = estrdup(var);
-
- /* Store the RAW variable internally */
- /* FIXME: Should not use php_register_variable_ex as that also registers
- * globals when register_globals is turned on */
- Z_STRLEN(raw_var) = val_len;
- Z_STRVAL(raw_var) = estrndup(*val, val_len + 1);
- Z_TYPE(raw_var) = IS_STRING;
-
- 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) == FS_UNSAFE_RAW)) {
- php_zval_filter(&new_var, IF_G(default_filter), IF_G(default_filter_flags), NULL, NULL/*charset*/ TSRMLS_CC);
- }
- }
-
- if (orig_array_ptr) {
- php_register_variable_ex(orig_var, &new_var, orig_array_ptr TSRMLS_CC);
- efree(orig_var);
- }
-
- if (retval) {
- if (new_val_len) {
- *new_val_len = Z_STRLEN(new_var);
- }
- efree(*val);
- if (Z_STRLEN(new_var)) {
- *val = estrndup(Z_STRVAL(new_var), Z_STRLEN(new_var) + 1);
- zval_dtor(&new_var);
- } else {
- *val = estrdup("");
- }
- }
-
- return retval;
-}
-/* }}} */
-
-/* {{{ static void php_zval_filter_recursive(zval *array, long filter, long flags, char *charset TSRMLS_DC)
- */
-static void php_zval_filter_recursive(zval *value, long filter, long flags, zval *options, char *charset TSRMLS_DC)
-{
- zval **element;
- HashPosition pos;
-
- if (Z_TYPE_P(value) == IS_ARRAY) {
- for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(value), &pos);
- zend_hash_get_current_data_ex(Z_ARRVAL_P(value), (void **) &element, &pos) == SUCCESS;
- zend_hash_move_forward_ex(Z_ARRVAL_P(value), &pos)) {
- php_zval_filter_recursive(*element, filter, flags, options, charset TSRMLS_CC);
- }
- } else {
- php_zval_filter(value, filter, flags, options, charset TSRMLS_CC);
- }
-}
-/* }}} */
-
-#define FIND_SOURCE(a,t) \
- array_ptr = IF_G(a); \
- break;
-
-/* {{{ proto mixed input_has_variable(constant type, string variable_name)
- */
-PHP_FUNCTION(input_has_variable)
-{
- long arg;
- char *var;
- int var_len;
- zval **tmp;
- zval *array_ptr = NULL;
- HashTable *hash_ptr;
- int found = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &arg, &var, &var_len) == FAILURE) {
- return;
- }
-
- switch (arg) {
- case PARSE_GET: FIND_SOURCE(get_array, TRACK_VARS_GET)
- case PARSE_POST: FIND_SOURCE(post_array, TRACK_VARS_POST)
- case PARSE_COOKIE: FIND_SOURCE(cookie_array, TRACK_VARS_COOKIE)
- case PARSE_SERVER: FIND_SOURCE(server_array, TRACK_VARS_SERVER)
- case PARSE_ENV: FIND_SOURCE(env_array, TRACK_VARS_ENV)
- }
-
- if (!array_ptr) {
- RETURN_FALSE;
- }
-
- if (!found) {
- hash_ptr = HASH_OF(array_ptr);
-
- if (hash_ptr && zend_hash_find(hash_ptr, var, var_len + 1, (void **)&tmp) == SUCCESS) {
- RETURN_TRUE;
- }
- }
-
- RETURN_FALSE;
-}
-/* }}} */
-
-/* {{{ proto mixed input_get(constant type, string variable_name [, int filter [, mixed flags [, string charset]]])
- */
-PHP_FUNCTION(input_get)
-{
- long arg, filter = FS_DEFAULT;
- char *var, *charset = NULL;
- int var_len, charset_len;
- zval *flags = NULL;
- zval **tmp;
- zval *array_ptr = NULL, *array_ptr2 = NULL, *array_ptr3 = NULL;
- HashTable *hash_ptr;
- int found = 0;
- int filter_flags = 0;
- zval *options = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls|lzs", &arg, &var, &var_len, &filter, &flags, &charset, &charset_len) == FAILURE) {
- return;
- }
-
- if (flags) {
- switch (Z_TYPE_P(flags)) {
- case IS_ARRAY:
- options = flags;
- break;
-
- case IS_STRING:
- case IS_BOOL:
- case IS_LONG:
- convert_to_long(flags);
- filter_flags = Z_LVAL_P(flags);
- options = NULL;
- break;
- }
- }
-
- switch(arg) {
- case PARSE_GET: FIND_SOURCE(get_array, TRACK_VARS_GET)
- case PARSE_POST: FIND_SOURCE(post_array, TRACK_VARS_POST)
- case PARSE_COOKIE: FIND_SOURCE(cookie_array, TRACK_VARS_COOKIE)
- case PARSE_SERVER: FIND_SOURCE(server_array, TRACK_VARS_SERVER)
- case PARSE_ENV: FIND_SOURCE(env_array, TRACK_VARS_ENV)
-
- case PARSE_SESSION:
- /* FIXME: Implement session source */
- break;
-
- case PARSE_REQUEST:
- if (PG(variables_order)) {
- zval **a_ptr = &array_ptr;
- char *p, *variables_order = PG(variables_order);
-
- for (p = variables_order; p && *p; p++) {
- switch (*p) {
- case 'p':
- case 'P':
- if (IF_G(default_filter) != FS_UNSAFE_RAW) {
- *a_ptr = IF_G(post_array);
- } else {
- *a_ptr = PG(http_globals)[TRACK_VARS_POST];
- }
- break;
- case 'g':
- case 'G':
- if (IF_G(default_filter) != FS_UNSAFE_RAW) {
- *a_ptr = IF_G(get_array);
- } else {
- *a_ptr = PG(http_globals)[TRACK_VARS_GET];
- }
- break;
- case 'c':
- case 'C':
- if (IF_G(default_filter) != FS_UNSAFE_RAW) {
- *a_ptr = IF_G(cookie_array);
- } else {
- *a_ptr = PG(http_globals)[TRACK_VARS_COOKIE];
- }
- break;
- }
- if (array_ptr && !array_ptr2) {
- a_ptr = &array_ptr2;
- continue;
- }
- if (array_ptr2 && !array_ptr3) {
- a_ptr = &array_ptr3;
- }
- }
- } else {
- FIND_SOURCE(get_array, TRACK_VARS_GET)
- }
-
- }
-
- if (!array_ptr) {
- RETURN_FALSE;
- }
-
- if (array_ptr3) {
- hash_ptr = HASH_OF(array_ptr3);
- if (hash_ptr && zend_hash_find(hash_ptr, var, var_len + 1, (void **)&tmp) == SUCCESS) {
- *return_value = **tmp;
- found = 1;
- }
- }
-
- if (array_ptr2 && !found) {
- hash_ptr = HASH_OF(array_ptr2);
- if (hash_ptr && zend_hash_find(hash_ptr, var, var_len + 1, (void **)&tmp) == SUCCESS) {
- *return_value = **tmp;
- found = 1;
- }
- }
-
- if (!found) {
- hash_ptr = HASH_OF(array_ptr);
-
- if (hash_ptr && zend_hash_find(hash_ptr, var, var_len + 1, (void **)&tmp) == SUCCESS) {
- *return_value = **tmp;
- found = 1;
- }
- }
-
- if (found) {
- zval_copy_ctor(return_value); /* Watch out for empty strings */
- php_zval_filter_recursive(return_value, filter, filter_flags, options, charset TSRMLS_CC);
- } else {
- RETVAL_FALSE;
- }
-}
-/* }}} */
-
-/* {{{ proto input_filters_list()
- * Returns a list of all supported filters */
-PHP_FUNCTION(input_filters_list)
-{
- int i, size = sizeof(filter_list) / sizeof(filter_list_entry);
-
- array_init(return_value);
- for (i = 0; i < size; ++i) {
- add_next_index_string(return_value, filter_list[i].name, 1);
- }
-}
-/* }}} */
-
-/* {{{ proto input_name_to_filter(string filtername)
- * Returns the filter ID belonging to a named filter */
-PHP_FUNCTION(input_name_to_filter)
-{
- int i, filter_len;
- int size = sizeof(filter_list) / sizeof(filter_list_entry);
- char *filter;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filter, &filter_len) == FAILURE) {
- return;
- }
-
- for (i = 0; i < size; ++i) {
- if (strcmp(filter_list[i].name, filter) == 0) {
- RETURN_LONG(filter_list[i].id);
- }
- }
- RETURN_NULL();
-}
-/* }}} */
-
-/* {{{ proto filter_data(mixed variable, int filter [, mixed filter_options [, string charset ]])
- */
-PHP_FUNCTION(filter_data)
-{
- long filter = FS_DEFAULT;
- char *charset = NULL;
- int charset_len;
- zval *var, *flags = NULL;
- int filter_flags = 0;
- zval *options = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/l|zs", &var, &filter, &flags, &charset, &charset_len) == FAILURE) {
- return;
- }
-
- if (filter != FC_CALLBACK) {
- if (flags) {
- switch (Z_TYPE_P(flags)) {
- case IS_ARRAY:
- options = flags;
- break;
-
- case IS_STRING:
- case IS_BOOL:
- case IS_LONG:
- convert_to_long(flags);
- filter_flags = Z_LVAL_P(flags);
- options = NULL;
- break;
- }
- }
- } else {
- if (flags) {
- switch (Z_TYPE_P(flags)) {
- case IS_ARRAY:
- case IS_STRING:
- options = flags;
- break;
-
- default:
- convert_to_string(flags);
- options = flags;
- break;
- }
- }
- }
- php_zval_filter_recursive(var, filter, filter_flags, options, charset TSRMLS_CC);
- RETURN_ZVAL(var, 1, 0);
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
View
87 ext/filter/filter_private.h
@@ -1,87 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Derick Rethans <derick@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef FILTER_PRIVATE_H
-#define FILTER_PRIVATE_H
-
-#define FILTER_FLAG_NONE 0x0000
-
-#define FILTER_FLAG_ALLOW_OCTAL 0x0001
-#define FILTER_FLAG_ALLOW_HEX 0x0002
-
-#define FILTER_FLAG_STRIP_LOW 0x0004
-#define FILTER_FLAG_STRIP_HIGH 0x0008
-#define FILTER_FLAG_ENCODE_LOW 0x0010
-#define FILTER_FLAG_ENCODE_HIGH 0x0020
-#define FILTER_FLAG_ENCODE_AMP 0x0040
-#define FILTER_FLAG_NO_ENCODE_QUOTES 0x0080
-#define FILTER_FLAG_EMPTY_STRING_NULL 0x0100
-
-#define FILTER_FLAG_ALLOW_FRACTION 0x1000
-#define FILTER_FLAG_ALLOW_THOUSAND 0x2000
-#define FILTER_FLAG_ALLOW_SCIENTIFIC 0x4000
-
-#define FILTER_FLAG_SCHEME_REQUIRED 0x010000
-#define FILTER_FLAG_HOST_REQUIRED 0x020000
-#define FILTER_FLAG_PATH_REQUIRED 0x040000
-#define FILTER_FLAG_QUERY_REQUIRED 0x080000
-
-#define FILTER_FLAG_IPV4 0x100000
-#define FILTER_FLAG_IPV6 0x200000
-#define FILTER_FLAG_NO_RES_RANGE 0x400000
-#define FILTER_FLAG_NO_PRIV_RANGE 0x800000
-
-#define FL_INT 0x0101
-#define FL_BOOLEAN 0x0102
-#define FL_FLOAT 0x0103
-
-#define FL_REGEXP 0x0110
-#define FL_URL 0x0111
-#define FL_EMAIL 0x0112
-#define FL_IP 0x0113
-
-#define FL_ALL 0x0100
-
-#define FS_DEFAULT 0x0201
-
-#define FS_STRING 0x0201
-#define FS_ENCODED 0x0202
-#define FS_SPECIAL_CHARS 0x0203
-#define FS_UNSAFE_RAW 0x0204
-#define FS_EMAIL 0x0205
-#define FS_URL 0x0206
-#define FS_NUMBER_INT 0x0207
-#define FS_NUMBER_FLOAT 0x0208
-#define FS_MAGIC_QUOTES 0x0209
-
-#define FS_ALL 0x0200
-
-#define FC_CALLBACK 0x0400
-
-#endif /* FILTER_PRIVATE_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
View
53 ext/filter/package.xml
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!DOCTYPE package SYSTEM "../pear/package.dtd">
-<package>
- <name>filter</name>
- <summary>Extension for safely dealing with input parameters</summary>
- <maintainers>
- <maintainer>
- <user>derick</user>
- <name>Derick Rethans</name>
- <email>derick@php.net</email>
- <role>lead</role>
- </maintainer>
- <maintainer>
- <user>rasmus</user>
- <name>Rasmus Lerdorf</name>
- <email>rasmus@php.net</email>
- <role>lead</role>
- </maintainer>
- </maintainers>
- <description>
-The Input Filter extension is meant to address this issue by implementing a set
-of filters and mechanisms that users can use to safely access their input data.
- </description>
- <license>PHP</license>
- <release>
- <state>beta</state>
- <version>0.9.3</version>
- <date>2005-11-18</date>
- <notes>
-- Fixed PECL bug #5960: Build with PHP's PCRE headers
-- Fixed PECL bug #5962: Postive float returned when negative float given
-- Fixed PECL bug #5963: Segmentation fault when passing anything other than strings
-
-- Added PECL FR #5961: Support other cases of "On", "Off", "True", and "False"
- </notes>
- <filelist>
- <file role="src" name="config.m4"/>
- <file role="src" name="config.w32"/>
- <file role="src" name="filter.c"/>
- <file role="src" name="filter_private.h"/>
- <file role="src" name="callback_filter.c"/>
- <file role="src" name="logical_filters.c"/>
- <file role="src" name="sanitizing_filters.c"/>
- <file role="src" name="php_filter.h"/>
- <file role="doc" name="CREDITS"/>
- </filelist>
- <deps>
- </deps>
- </release>
-</package>
-<!--
-vim:et:ts=1:sw=1
--->
View
68 ext/filter/package2.xml
@@ -1,68 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<package packagerversion="1.4.4" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
-http://pear.php.net/dtd/tasks-1.0.xsd
-http://pear.php.net/dtd/package-2.0
-http://pear.php.net/dtd/package-2.0.xsd">
- <name>filter</name>
- <channel>pecl.php.net</channel>
- <summary>Extension for safely dealing with input parameters</summary>
- <description>The Input Filter extension is meant to address this issue by implementing a set
-of filters and mechanisms that users can use to safely access their input data.
-
- </description>
- <lead>
- <name>Derick Rethans</name>
- <user>derick</user>
- <email>derick@php.net</email>
- <active>yes</active>
- </lead>
- <lead>
- <name>Rasmus Lerdorf</name>
- <user>rasmus</user>
- <email>rasmus@php.net</email>
- <active>yes</active>
- </lead>
- <date>2005-11-18</date>
- <time>10:55:41</time>
- <version>
- <release>0.9.3</release>
- <api>0.9.3</api>
- </version>
- <stability>
- <release>beta</release>
- <api>beta</api>
- </stability>
- <license uri="http://www.php.net/license">PHP</license>
- <notes>- Fixed PECL bug #5960: Build with PHP&apos;s PCRE headers
-- Fixed PECL bug #5962: Postive float returned when negative float given
-- Fixed PECL bug #5963: Segmentation fault when passing anything other than strings
-
-- Added PECL FR #5961: Support other cases of &quot;On&quot;, &quot;Off&quot;, &quot;True&quot;, and &quot;False&quot;
-
- </notes>
- <contents>
- <dir name="/">
- <file name="callback_filter.c" role="src" />
- <file name="config.m4" role="src" />
- <file name="config.w32" role="src" />
- <file name="CREDITS" role="doc" />
- <file name="filter.c" role="src" />
- <file name="filter_private.h" role="src" />
- <file name="logical_filters.c" role="src" />
- <file name="php_filter.h" role="src" />
- <file name="sanitizing_filters.c" role="src" />
- </dir> <!-- / -->
- </contents>
- <dependencies>
- <required>
- <php>
- <min>4.0.0</min>
- </php>
- <pearinstaller>
- <min>1.4.0b1</min>
- </pearinstaller>
- </required>
- </dependencies>
- <providesextension>filter</providesextension>
- <extsrcrelease />
-</package>
View
105 ext/filter/php_filter.h
@@ -1,105 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Rasmus Lerdorf <rasmus@php.net> |
- | Derick Rethans <derick@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_FILTER_H
-#define PHP_FILTER_H
-
-#include "SAPI.h"
-#include "zend_API.h"
-#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "ext/standard/php_string.h"
-#include "php_variables.h"
-
-extern zend_module_entry filter_module_entry;
-#define phpext_filter_ptr &filter_module_entry
-
-#ifdef PHP_WIN32
-#define PHP_FILTER_API __declspec(dllexport)
-#else
-#define PHP_FILTER_API
-#endif
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-PHP_MINIT_FUNCTION(filter);
-PHP_MSHUTDOWN_FUNCTION(filter);
-PHP_RINIT_FUNCTION(filter);
-PHP_RSHUTDOWN_FUNCTION(filter);
-PHP_MINFO_FUNCTION(filter);
-
-PHP_FUNCTION(input_get);
-PHP_FUNCTION(input_filters_list);
-PHP_FUNCTION(input_has_variable);
-PHP_FUNCTION(input_name_to_filter);
-PHP_FUNCTION(filter_data);
-
-ZEND_BEGIN_MODULE_GLOBALS(filter)
- zval *post_array;
- zval *get_array;
- zval *cookie_array;
- zval *env_array;
- zval *server_array;
- zval *session_array;
- long default_filter;
- long default_filter_flags;
-ZEND_END_MODULE_GLOBALS(filter)
-
-#ifdef ZTS
-#define IF_G(v) TSRMG(filter_globals_id, zend_filter_globals *, v)
-#else
-#define IF_G(v) (filter_globals.v)
-#endif
-
-
-#define PHP_INPUT_FILTER_PARAM_DECL zval *value, long flags, zval *option_array, char *charset TSRMLS_DC
-void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL);
-
-void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_encoded(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_special_chars(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL);
-void php_filter_email(PHP_INPUT_FILTER_PARAM_DECL);
-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_magic_quotes(PHP_INPUT_FILTER_PARAM_DECL);
-
-void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL);
-
-#endif /* FILTER_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * indent-tabs-mode: t
- * End:
- */
View
340 ext/filter/sanitizing_filters.c
@@ -1,340 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2006 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Authors: Derick Rethans <derick@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#include "php_filter.h"
-#include "filter_private.h"
-#include "ext/standard/php_smart_str.h"
-
-/* {{{ STRUCTS */
-typedef unsigned long filter_map[256];
-/* }}} */
-
-/* {{{ HELPER FUNCTIONS */
-static void php_filter_encode_html(zval *value, char* chars, int encode_nul)
-{
- register int x, y;
- smart_str str = {0};
- int len = Z_STRLEN_P(value);
- char *s = Z_STRVAL_P(value);
-
- if (Z_STRLEN_P(value) == 0) {
- return;
- }
-
- for (x = 0, y = 0; len--; x++, y++) {
- if (strchr(chars, s[x]) || (encode_nul && s[x] == 0)) {
- smart_str_appendl(&str, "&#", 2);
- smart_str_append_long(&str, s[x]);
- smart_str_appendc(&str, ';');
- } else {
- smart_str_appendc(&str, s[x]);
- }
- }
- smart_str_0(&str);
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = str.c;
- Z_STRLEN_P(value) = str.len;
-}
-
-static void php_filter_encode_html_high_low(zval *value, long flags)
-{
- register int x, y;
- smart_str str = {0};
- int len = Z_STRLEN_P(value);
- unsigned char *s = Z_STRVAL_P(value);
-
- if (Z_STRLEN_P(value) == 0) {
- return;
- }
-
- for (x = 0, y = 0; len--; x++, y++) {
- if (((flags & FILTER_FLAG_ENCODE_LOW) && (s[x] < 32)) || ((flags & FILTER_FLAG_ENCODE_HIGH) && (s[x] > 127))) {
- smart_str_appendl(&str, "&#", 2);
- smart_str_append_long(&str, s[x]);
- smart_str_appendc(&str, ';');
- } else {
- smart_str_appendc(&str, s[x]);
- }
- }
- smart_str_0(&str);
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = str.c;
- Z_STRLEN_P(value) = str.len;
-}
-
-static unsigned char hexchars[] = "0123456789ABCDEF";
-
-#define LOWALPHA "abcdefghijklmnopqrstuvwxyz"
-#define HIALPHA "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-#define DIGIT "0123456789"
-
-#define DEFAULT_URL_ENCODE LOWALPHA HIALPHA DIGIT "-._"
-
-static void php_filter_encode_url(zval *value, char* chars, int high, int low, int encode_nul)
-{
- register int x, y;
- unsigned char *str;
- int len = Z_STRLEN_P(value);
- char *s = Z_STRVAL_P(value);
-
- str = (unsigned char *) safe_emalloc(3, len, 1);
- for (x = 0, y = 0; len--; x++, y++) {
- str[y] = (unsigned char) s[x];
-
- if ((strlen(chars) && !strchr(chars, str[y])) || (high && str[y] > 127) || (low && str[y] < 32) || (encode_nul && str[y] == 0)) {
- str[y++] = '%';
- str[y++] = hexchars[(unsigned char) s[x] >> 4];
- str[y] = hexchars[(unsigned char) s[x] & 15];
- }
- }
- str[y] = '\0';
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = str;
- Z_STRLEN_P(value) = y;
-}
-
-static void php_filter_strip(zval *value, long flags)
-{
- unsigned char *buf, *str;
- int i, c;
-
- /* Optimization for if no strip flags are set */
- if (! ((flags & FILTER_FLAG_STRIP_LOW) || (flags & FILTER_FLAG_STRIP_HIGH)) ) {
- return;
- }
-
- str = Z_STRVAL_P(value);
- buf = safe_emalloc(1, Z_STRLEN_P(value) + 1, 1);
- c = 0;
- for (i = 0; i < Z_STRLEN_P(value); i++) {
- if ((str[i] > 127) && (flags & FILTER_FLAG_STRIP_HIGH)) {
- } else if ((str[i] < 32) && (flags & FILTER_FLAG_STRIP_LOW)) {
- } else {
- buf[c] = str[i];
- ++c;
- }
- }
- /* update zval string data */
- buf[c] = '\0';
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = buf;
- Z_STRLEN_P(value) = c;
-}
-/* }}} */
-
-/* {{{ FILTER MAP HELPERS */
-static void filter_map_init(filter_map *map)
-{
- memset(map, 0, sizeof(filter_map));
-}
-
-static void filter_map_update(filter_map *map, int flag, unsigned char *allowed_list)
-{
- int l, i;
-
- l = strlen(allowed_list);
- for (i = 0; i < l; ++i) {
- (*map)[allowed_list[i]] = flag;
- }
-}
-
-static void filter_map_apply(zval *value, filter_map *map)
-{
- unsigned char *buf, *str;
- int i, c;
-
- str = Z_STRVAL_P(value);
- buf = safe_emalloc(1, Z_STRLEN_P(value) + 1, 1);
- c = 0;
- for (i = 0; i < Z_STRLEN_P(value); i++) {
- if ((*map)[str[i]]) {
- buf[c] = str[i];
- ++c;
- }
- }
- /* update zval string data */
- buf[c] = '\0';
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = buf;
- Z_STRLEN_P(value) = c;
-}
-/* }}} */
-
-
-/* {{{ php_filter_string */
-void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL)
-{
- size_t new_len;
-
- /* strip tags, implicitly also removes \0 chars */
- new_len = php_strip_tags(Z_STRVAL_P(value), Z_STRLEN_P(value), NULL, NULL, 0);
- Z_STRLEN_P(value) = new_len;
-
- if (new_len == 0) {
- zval_dtor(value);
- Z_TYPE_P(value) = IS_NULL;
- return;
- }
-
- if (! (flags & FILTER_FLAG_NO_ENCODE_QUOTES)) {
- /* encode ' and " to numerical entity */
- php_filter_encode_html(value, "'\"", 0);
- }
- /* strip high/strip low ( see flags )*/
- php_filter_strip(value, flags);
-
- /* encode low/encode high flags */
- php_filter_encode_html_high_low(value, flags);
-
- /* also all the flags - & encode as %xx */
- if (flags & FILTER_FLAG_ENCODE_AMP) {
- php_filter_encode_html(value, "&", 0);
- }
-}
-/* }}} */
-
-/* {{{ php_filter_encoded */
-void php_filter_encoded(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* apply strip_high and strip_low filters */
- php_filter_strip(value, flags);
- /* urlencode */
- php_filter_encode_url(value, DEFAULT_URL_ENCODE, flags & FILTER_FLAG_ENCODE_HIGH, flags & FILTER_FLAG_ENCODE_LOW, 1);
-}
-/* }}} */
-
-/* {{{ php_filter_special_chars */
-void php_filter_special_chars(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* encodes ' " < > & \0 to numerical entities */
- php_filter_encode_html(value, "'\"<>&", 1);
- /* if strip low is not set, then we encode them as &#xx; */
- php_filter_strip(value, flags);
- php_filter_encode_html_high_low(value, FILTER_FLAG_ENCODE_LOW | flags);
-}
-/* }}} */
-
-/* {{{ php_filter_unsafe_raw */
-void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* Only if no flags are set (optimization) */
- if (flags != 0 && Z_STRLEN_P(value) > 0) {
- php_filter_strip(value, flags);
- if (flags & FILTER_FLAG_ENCODE_AMP) {
- php_filter_encode_html(value, "&", 0);
- }
- php_filter_encode_html_high_low(value, flags);
- }
-}
-/* }}} */
-
-/* {{{ php_filter_email */
-#define SAFE "$-_.+"
-#define EXTRA "!*'(),"
-#define NATIONAL "{}|\\^~[]`"
-#define PUNCTUATION "<>#%\""
-#define RESERVED ";/?:@&="
-
-void php_filter_email(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* Check section 6 of rfc 822 http://www.faqs.org/rfcs/rfc822.html */
- unsigned char *allowed_list = LOWALPHA HIALPHA DIGIT "!#$%&'*+-/=?^_`{|}~@.[]";
- filter_map map;
-
- filter_map_init(&map);
- filter_map_update(&map, 1, allowed_list);
- filter_map_apply(value, &map);
-}
-/* }}} */
-
-/* {{{ php_filter_url */
-void php_filter_url(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* Strip all chars not part of section 5 of
- * http://www.faqs.org/rfcs/rfc1738.html */
- unsigned char *allowed_list = LOWALPHA HIALPHA DIGIT SAFE EXTRA NATIONAL PUNCTUATION RESERVED;
- filter_map map;
-
- filter_map_init(&map);
- filter_map_update(&map, 1, allowed_list);
- filter_map_apply(value, &map);
-}
-/* }}} */
-
-/* {{{ php_filter_number_int */
-void php_filter_number_int(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* strip everything [^0-9+-] */
- unsigned char *allowed_list = "+-" DIGIT;
- filter_map map;
-
- filter_map_init(&map);
- filter_map_update(&map, 1, allowed_list);
- filter_map_apply(value, &map);
-}
-/* }}} */
-
-/* {{{ php_filter_number_float */
-void php_filter_number_float(PHP_INPUT_FILTER_PARAM_DECL)
-{
- /* strip everything [^0-9+-] */
- unsigned char *allowed_list = "+-" DIGIT;
- filter_map map;
-
- filter_map_init(&map);
- filter_map_update(&map, 1, allowed_list);
-
- /* depending on flags, strip '.', 'e', ",", "'" */
- if (flags & FILTER_FLAG_ALLOW_FRACTION) {
- filter_map_update(&map, 2, ".");
- }
- if (flags & FILTER_FLAG_ALLOW_THOUSAND) {
- filter_map_update(&map, 3, ",");
- }
- if (flags & FILTER_FLAG_ALLOW_SCIENTIFIC) {
- filter_map_update(&map, 4, "eE");
- }
- filter_map_apply(value, &map);
-}
-/* }}} */
-
-/* {{{ php_filter_magic_quotes */
-void php_filter_magic_quotes(PHP_INPUT_FILTER_PARAM_DECL)
-{
- char *buf;
- int len;
-
- /* just call php_addslashes quotes */
- buf = php_addslashes(Z_STRVAL_P(value), Z_STRLEN_P(value), &len, 0 TSRMLS_CC);
-
- efree(Z_STRVAL_P(value));
- Z_STRVAL_P(value) = buf;
- Z_STRLEN_P(value) = len;
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
View
8 ext/filter/tests/001.phpt
@@ -1,8 +0,0 @@
---TEST--
-Simple GET test
---GET--
-a=1
---FILE--
-<?php echo $_GET['a']; ?>
---EXPECT--
-1
View
11 ext/filter/tests/002.phpt
@@ -1,11 +0,0 @@
---TEST--
-GET test with 2 values and an empty one
---GET--
-a=1&b=&c=3
---FILE--
-<?php echo $_GET['a'];
-echo $_GET['b'];
-echo $_GET['c'];
-?>
---EXPECT--
-13
View
22 ext/filter/tests/003.phpt
@@ -1,22 +0,0 @@
---TEST--
-GET/POST/REQUEST Test
---POST--
-d=4&e=5
---GET--
-a=1&b=&c=3
---FILE--
-<?php echo $_GET['a'];
-echo $_GET['b'];
-echo $_GET['c'];
-echo $_POST['d'];
-echo $_POST['e'];
-echo "\n";
-echo $_REQUEST['a'];
-echo $_REQUEST['b'];
-echo $_REQUEST['c'];
-echo $_REQUEST['d'];
-echo $_REQUEST['e'];
-?>
---EXPECT--
-1345
-1345
View
24 ext/filter/tests/004.phpt
@@ -1,24 +0,0 @@
---TEST--
-GET/POST/REQUEST Test with filtered data
---INI--
-filter.default=special_chars
---POST--
-d="quotes"&e=\slash
---GET--
-a=O'Henry&b=&c=<b>Bold</b>
---FILE--
-<?php echo $_GET['a'];
-echo $_GET['b'];
-echo $_GET['c'];
-echo $_POST['d'];
-echo $_POST['e'];
-echo "\n";
-echo $_REQUEST['a'];
-echo $_REQUEST['b'];
-echo $_REQUEST['c'];
-echo $_REQUEST['d'];
-echo $_REQUEST['e'];
-?>
---EXPECT--
-O&#39;HenryBold&quot;quotes&quot;\slash
-O&#39;HenryBold&quot;quotes&quot;\slash
View
21 ext/filter/tests/005.phpt
@@ -1,21 +0,0 @@
---TEST--
-GET/REQUEST Test with fifa example data
---INI--
-filter.default=stripped
---GET--
-id=f03_photos&pgurl=http%3A//fifaworldcup.yahoo.com/03/en/photozone/index.html
---FILE--
-<?php
-echo $_GET['id'];
-echo "\n";
-echo $_GET['pgurl'];
-echo "\n";
-echo $_REQUEST['id'];
-echo "\n";
-echo $_REQUEST['pgurl'];
-?>
---EXPECT--
-f03_photos
-http://fifaworldcup.yahoo.com/03/en/photozone/index.html
-f03_photos
-http://fifaworldcup.yahoo.com/03/en/photozone/index.html
View
10 ext/filter/tests/006.phpt
@@ -1,10 +0,0 @@
---TEST--
-filter() test
---POST--
-foo=<b>abc</b>
---FILE--
-<?php
-echo input_get(INPUT_POST, 'foo', FS_STRIPPED);
-?>
---EXPECT--
-abc
View
68 ext/filter/tests/007.phpt
@@ -1,68 +0,0 @@
---TEST--
-input_has_variable()
---GET--
-a=qwe&abc=<a>href</a>
---POST--
-b=qwe&bbc=<a>href</a>
---FILE--
-<?php
-
-var_dump(input_has_variable(INPUT_GET, "a"));
-var_dump(input_has_variable(INPUT_GET, "abc"));
-var_dump(input_has_variable(INPUT_GET, "nonex"));
-var_dump(input_has_variable(INPUT_GET, " "));
-var_dump(input_has_variable(INPUT_GET, ""));
-var_dump(input_has_variable(INPUT_GET, array()));
-
-var_dump(input_has_variable(INPUT_POST, "b"));
-var_dump(input_has_variable(INPUT_POST, "bbc"));
-var_dump(input_has_variable(INPUT_POST, "nonex"));
-var_dump(input_has_variable(INPUT_POST, " "));
-var_dump(input_has_variable(INPUT_POST, ""));
-var_dump(input_has_variable(INPUT_POST, array()));
-
-var_dump(input_has_variable(-1, ""));
-var_dump(input_has_variable("", ""));
-var_dump(input_has_variable(array(), array()));
-var_dump(input_has_variable(array(), ""));
-var_dump(input_has_variable("", array()));
-
-echo "Done\n";
-?>
---EXPECTF--
-bool(true)
-bool(true)
-bool(false)
-bool(false)
-bool(false)
-PHP Warning: input_has_variable() expects parameter 2 to be string, array given in %s on line %d
-
-Warning: input_has_variable() expects parameter 2 to be string, array given in %s on line %d
-NULL
-bool(true)
-bool(true)
-bool(false)
-bool(false)
-bool(false)
-PHP Warning: input_has_variable() expects parameter 2 to be string, array given in %s on line %d
-
-Warning: input_has_variable() expects parameter 2 to be string, array given in %s on line %d
-NULL
-bool(false)
-PHP Warning: input_has_variable() expects parameter 1 to be long, string given in %s on line %d
-
-Warning: input_has_variable() expects parameter 1 to be long, string given in %s on line %d
-NULL
-PHP Warning: input_has_variable() expects parameter 1 to be long, array given in %s on line %d
-
-Warning: input_has_variable() expects parameter 1 to be long, array given in %s on line %d
-NULL
-PHP Warning: input_has_variable() expects parameter 1 to be long, array given in %s on line %d
-
-Warning: input_has_variable() expects parameter 1 to be long, array given in %s on line %d
-NULL
-PHP Warning: input_has_variable() expects parameter 1 to be long, string given in %s on line %d
-
-Warning: input_has_variable() expects parameter 1 to be long, string given in %s on line %d
-NULL
-Done
View
88 ext/filter/tests/008.phpt
@@ -1,88 +0,0 @@
---TEST--
-input_filters_list()
---FILE--
-<?php
-
-var_dump(input_filters_list());
-var_dump(input_filters_list(array()));
-
-echo "Done\n";
-?>
---EXPECTF--
-array(18) {
- [0]=>
- string(3) "int"
- [1]=>
- string(7) "boolean"
- [2]=>
- string(5) "float"
- [3]=>
- string(15) "validate_regexp"
- [4]=>
- string(12) "validate_url"
- [5]=>
- string(14) "validate_email"
- [6]=>
- string(11) "validate_ip"
- [7]=>
- string(6) "string"
- [8]=>
- string(8) "stripped"
- [9]=>
- string(7) "encoded"
- [10]=>
- string(13) "special_chars"
- [11]=>
- string(10) "unsafe_raw"
- [12]=>
- string(5) "email"
- [13]=>
- string(3) "url"
- [14]=>
- string(10) "number_int"
- [15]=>
- string(12) "number_float"
- [16]=>
- string(12) "magic_quotes"
- [17]=>
- string(8) "callback"
-}
-array(18) {
- [0]=>
- string(3) "int"
- [1]=>
- string(7) "boolean"
- [2]=>
- string(5) "float"
- [3]=>
- string(15) "validate_regexp"
- [4]=>
- string(12) "validate_url"
- [5]=>
- string(14) "validate_email"
- [6]=>
- string(11) "validate_ip"
- [7]=>
- string(6) "string"
- [8]=>
- string(8) "stripped"
- [9]=>
- string(7) "encoded"
- [10]=>
- string(13) "special_chars"
- [11]=>
- string(10) "unsafe_raw"
- [12]=>
- string(5) "email"
- [13]=>
- string(3) "url"
- [14]=>
- string(10) "number_int"
- [15]=>
- string(12) "number_float"
- [16]=>
- string(12) "magic_quotes"
- [17]=>
- string(8) "callback"
-}
-Done
View
30 ext/filter/tests/009.phpt
@@ -1,30 +0,0 @@
---TEST--
-input_name_to_filter()
---FILE--
-<?php
-
-var_dump(input_name_to_filter("stripped"));
-var_dump(input_name_to_filter("string"));
-var_dump(input_name_to_filter("url"));
-var_dump(input_name_to_filter("int"));
-var_dump(input_name_to_filter("none"));
-var_dump(input_name_to_filter(array()));
-var_dump(input_name_to_filter(-1));
-var_dump(input_name_to_filter(0,0,0));
-
-echo "Done\n";
-?>
---EXPECTF--
-int(513)
-int(513)
-int(518)
-int(257)
-NULL
-
-Warning: input_name_to_filter() expects parameter 1 to be string, array given in %s on line %d
-NULL
-NULL
-
-Warning: input_name_to_filter() expects exactly 1 parameter, 3 given in %s on line %d
-NULL
-Done
View
60 ext/filter/tests/010.phpt
@@ -1,60 +0,0 @@
---TEST--
-filter_data()
---FILE--
-<?php
-
-var_dump(filter_data(array(1,"1","", "-23234", "text", "asdf234asdfgs", array()), FL_INT));
-var_dump(filter_data(array(1.2,"1.7","", "-23234.123", "text", "asdf234.2asdfgs", array()), FL_FLOAT));
-var_dump(filter_data(1, array()));
-var_dump(filter_data(1, FS_STRING, 1));
-var_dump(filter_data(1, FS_STRING, 0));
-var_dump(filter_data(1, FS_STRING, array()));
-var_dump(filter_data(1, -1, array(123)));
-var_dump(filter_data(1, 0, array()));
-
-echo "Done\n";
-?>
---EXPECTF--
-array(7) {
- [0]=>
- int(1)
- [1]=>
- int(1)
- [2]=>
- int(0)
- [3]=>
- int(-23234)
- [4]=>
- NULL
- [5]=>
- NULL
- [6]=>
- array(0) {
- }
-}
-array(7) {
- [0]=>
- float(1.2)
- [1]=>
- float(1.7)
- [2]=>
- float(0)
- [3]=>
- float(-23234.123)
- [4]=>
- NULL
- [5]=>
- NULL
- [6]=>
- array(0) {
- }
-}
-
-Warning: filter_data() expects parameter 2 to be long, array given in %s on line %d
-NULL
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-string(1) "1"
-Done
View
49 ext/filter/tests/011.phpt
@@ -1,49 +0,0 @@
---TEST--
-input_get()
---GET--
-a=<b>test</b>&b=http://example.com
---POST--
-c=<p>string</p>&d=12345.7
---FILE--
-<?php
-
-var_dump(input_get(INPUT_GET, "a", FS_STRIPPED));
-var_dump(input_get(INPUT_GET, "b", FS_URL));
-var_dump(input_get(INPUT_GET, "a", FS_SPECIAL_CHARS, array(1,2,3,4,5)));
-var_dump(input_get(INPUT_GET, "b", FL_FLOAT, new stdClass));
-var_dump(input_get(INPUT_POST, "c", FS_STRIPPED, array(5,6,7,8)));
-var_dump(input_get(INPUT_POST, "d", FL_FLOAT));
-var_dump(input_get(INPUT_POST, "c", FS_SPECIAL_CHARS));
-var_dump(input_get(INPUT_POST, "d", FL_INT));
-
-var_dump(input_get(new stdClass, "d"));
-
-var_dump(input_get(INPUT_POST, "c", "", ""));
-var_dump(input_get("", "", "", "", ""));
-var_dump(input_get(0, 0, 0, 0, 0));
-
-echo "Done\n";
-?>
---EXPECTF--
-string(4) "test"
-string(18) "http://example.com"
-string(27) "&#60;b&#62;test&#60;/b&#62;"
-NULL
-string(6) "string"
-float(12345.7)
-string(29) "&#60;p&#62;string&#60;/p&#62;"
-NULL
-PHP Warning: input_get() expects parameter 1 to be long, object given in %s on line %d
-
-Warning: input_get() expects parameter 1 to be long, object given in %s on line %d
-NULL
-PHP Warning: input_get() expects parameter 3 to be long, string given in %s on line %d
-
-Warning: input_get() expects parameter 3 to be long, string given in %s on line %d
-NULL
-PHP Warning: input_get() expects parameter 1 to be long, string given in %s on line %d
-
-Warning: input_get() expects parameter 1 to be long, string given in %s on line %d
-NULL
-bool(false)
-Done
View
16 ext/filter/tests/012.phpt
@@ -1,16 +0,0 @@
---TEST--
-input_get()
---FILE--
-<?php
-
-var_dump(input_get(INPUT_GET, "test"));
-var_dump(input_get(INPUT_POST, "test"));
-var_dump(input_get(INPUT_COOKIE, ""));
-
-echo "Done\n";
-?>
---EXPECT--
-bool(false)
-bool(false)
-bool(false)
-Done
View
40 ext/filter/tests/013.phpt
@@ -1,40 +0,0 @@
---TEST--
-filter_data() and flags
---FILE--
-<?php
-
-var_dump(filter_data("0xff", FL_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("07", FL_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL)));
-var_dump(filter_data("0xff0000", FL_INT, array("flags"=>FILTER_FLAG_ALLOW_HEX)));
-var_dump(filter_data("0666", FL_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL)));
-
-var_dump(filter_data("6", FL_INT, array("min_range"=>1, "max_range"=>7)));
-var_dump(filter_data("6", FL_INT, array("min_range"=>0, "max_range"=>5)));
-var_dump(filter_data(-1, FL_INT, array("min_range"=>1, "max_range"=>7)));
-var_dump(filter_data(-1, FL_INT, array("min_range"=>-4, "max_range"=>7)));
-
-var_dump(filter_data("", FL_INT, array("min_range"=>-4, "max_range"=>7)));
-var_dump(filter_data("", FL_INT, array("min_range"=>2, "max_range"=>7)));
-var_dump(filter_data("", FL_INT, array("min_range"=>-5, "max_range"=>-3)));
-var_dump(filter_data(345, FL_INT, array("min_range"=>500, "max_range"=>100)));
-var_dump(filter_data("0ff", FL_INT));
-var_dump(filter_data("010", FL_INT));
-
-echo "Done\n";
-?>
---EXPECT--
-int(255)
-int(7)
-int(16711680)
-int(438)
-int(6)
-NULL
-NULL
-int(-1)
-int(0)
-NULL
-NULL
-NULL
-NULL
-NULL
-Done
View
41 ext/filter/tests/014.phpt
@@ -1,41 +0,0 @@
---TEST--
-filter_data() and FL_BOOLEAN
---FILE--
-<?php
-
-var_dump(filter_data("no", FL_BOOLEAN));
-var_dump(filter_data(new stdClass, FL_BOOLEAN));
-var_dump(filter_data("yes", FL_BOOLEAN));
-var_dump(filter_data("true", FL_BOOLEAN));
-var_dump(filter_data("false", FL_BOOLEAN));
-var_dump(filter_data("off", FL_BOOLEAN));
-var_dump(filter_data("on", FL_BOOLEAN));
-var_dump(filter_data("0", FL_BOOLEAN));
-var_dump(filter_data("1", FL_BOOLEAN));
-var_dump(filter_data("NONE", FL_BOOLEAN));
-var_dump(filter_data("", FL_BOOLEAN));
-var_dump(filter_data(-1, FL_BOOLEAN));
-var_dump(filter_data("000000", FL_BOOLEAN));
-var_dump(filter_data("111111", FL_BOOLEAN));
-
-
-echo "Done\n";
-?>
---EXPECTF--
-bool(false)
-
-Notice: Object of class stdClass to string conversion in %s on line %d
-NULL
-bool(true)
-bool(true)
-bool(false)
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-NULL
-bool(false)
-NULL
-NULL
-NULL
-Done
View
72 ext/filter/tests/015.phpt
@@ -1,72 +0,0 @@
---TEST--
-filter_data() and FL_URL
---FILE--
-<?php
-
-$values = Array(
-'http://example.com/index.html',
-'http://www.example.com/index.php',
-'http://www.example/img/test.png',
-'http://www.example/img/dir/',
-'http://www.example/img/dir',
-'http//www.example/wrong/url/',
-'http:/www.example',
-'file:///tmp/test.c',
-'ftp://ftp.example.com/tmp/',
-'/tmp/test.c',
-'/',
-'http://',
-'http:/',
-'http:',
-'http',
-'',
--1,
-array(),
-);
-foreach ($values as $value) {
- var_dump(filter_data($value, FL_URL));
-}
-
-
-var_dump(filter_data("qwe", FL_URL, FILTER_FLAG_SCHEME_REQUIRED));
-var_dump(filter_data("http://qwe", FL_URL, FILTER_FLAG_SCHEME_REQUIRED));
-var_dump(filter_data("http://", FL_URL, FILTER_FLAG_HOST_REQUIRED));
-var_dump(filter_data("/tmp/test", FL_URL, FILTER_FLAG_HOST_REQUIRED));
-var_dump(filter_data("http://www.example.com", FL_URL, FILTER_FLAG_HOST_REQUIRED));
-var_dump(filter_data("http://www.example.com", FL_URL, FILTER_FLAG_PATH_REQUIRED));
-var_dump(filter_data("http://www.example.com/path/at/the/server/", FL_URL, FILTER_FLAG_PATH_REQUIRED));
-var_dump(filter_data("http://www.example.com/index.html", FL_URL, FILTER_FLAG_QUERY_REQUIRED));
-var_dump(filter_data("http://www.example.com/index.php?a=b&c=d", FL_URL, FILTER_FLAG_QUERY_REQUIRED));
-
-echo "Done\n";
-?>
---EXPECTF--
-string(29) "http://example.com/index.html"
-string(32) "http://www.example.com/index.php"
-string(31) "http://www.example/img/test.png"
-string(27) "http://www.example/img/dir/"
-string(26) "http://www.example/img/dir"
-string(28) "http//www.example/wrong/url/"
-string(17) "http:/www.example"
-string(18) "file:///tmp/test.c"
-string(26) "ftp://ftp.example.com/tmp/"
-string(11) "/tmp/test.c"
-string(1) "/"
-NULL
-string(6) "http:/"
-string(5) "http:"
-string(4) "http"
-string(0) ""
-string(2) "-1"
-array(0) {
-}
-NULL
-string(10) "http://qwe"
-NULL
-NULL
-string(22) "http://www.example.com"
-NULL
-string(42) "http://www.example.com/path/at/the/server/"
-NULL
-string(40) "http://www.example.com/index.php?a=b&c=d"
-Done
View
32 ext/filter/tests/016.phpt
@@ -1,32 +0,0 @@
---TEST--
-filter_data() and FL_EMAIL
---FILE--
-<?php
-$values = Array(
-'a@b.c',
-'abuse@example.com',
-'test!.!@#$%^&*@example.com',
-'test@@#$%^&*())).com',
-'test@.com',
-'test@com',
-'@',
-'[]()/@example.com',
-'QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET',
-);
-foreach ($values as $value) {
- var_dump(filter_data($value, FL_EMAIL));
-}
-
-echo "Done\n";
-?>
---EXPECT--
-string(5) "a@b.c"
-string(17) "abuse@example.com"
-NULL
-NULL
-NULL
-NULL
-NULL
-NULL
-string(57) "QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET"
-Done
View
24 ext/filter/tests/017.phpt
@@ -1,24 +0,0 @@
---TEST--
-filter_data() and FL_REGEXP
---FILE--
-<?php
-
-var_dump(filter_data("data", FL_REGEXP, array("regexp"=>'/.*/')));
-var_dump(filter_data("data", FL_REGEXP, array("regexp"=>'/^b(.*)/')));
-var_dump(filter_data("data", FL_REGEXP, array("regexp"=>'/^d(.*)/')));
-var_dump(filter_data("data", FL_REGEXP, array("regexp"=>'blah')));
-var_dump(filter_data("data", FL_REGEXP, array("regexp"=>'[')));
-var_dump(filter_data("data", FL_REGEXP));
-
-echo "Done\n";
-?>
---EXPECTF--
-string(4) "data"
-NULL
-string(4) "data"
-NULL
-NULL
-
-Warning: filter_data(): 'regexp' option missing in %s on line %d
-NULL
-Done
View
50 ext/filter/tests/018.phpt
@@ -1,50 +0,0 @@
---TEST--
-filter_data() and FL_IP
---FILE--
-<?php
-var_dump(filter_data("192.168.0.1", FL_IP));
-var_dump(filter_data("192.168.0.1.1", FL_IP));
-var_dump(filter_data("::1", FL_IP));
-var_dump(filter_data("fe00::0", FL_IP));
-var_dump(filter_data("::123456", FL_IP));
-var_dump(filter_data("::1::b", FL_IP));
-var_dump(filter_data("127.0.0.1", FL_IP));
-var_dump(filter_data("192.168.0.1", FL_IP, FILTER_FLAG_NO_PRIV_RANGE));
-var_dump(filter_data("192.0.34.166", FL_IP, FILTER_FLAG_NO_PRIV_RANGE));
-var_dump(filter_data("127.0.0.1", FL_IP, FILTER_FLAG_NO_RES_RANGE));
-var_dump(filter_data("192.0.0.1", FL_IP, FILTER_FLAG_NO_RES_RANGE));
-var_dump(filter_data("192.0.34.166", FL_IP));
-var_dump(filter_data("256.1237.123.1", FL_IP));
-var_dump(filter_data("255.255.255.255", FL_IP));
-var_dump(filter_data("255.255.255.255", FL_IP, FILTER_FLAG_NO_RES_RANGE));
-var_dump(filter_data("", FL_IP));
-var_dump(filter_data(-1, FL_IP));
-var_dump(filter_data("::1", FL_IP, FILTER_FLAG_IPV4));
-var_dump(filter_data("127.0.0.1", FL_IP, FILTER_FLAG_IPV6));
-var_dump(filter_data("::1", FL_IP, FILTER_FLAG_IPV6));
-var_dump(filter_data("127.0.0.1", FL_IP, FILTER_FLAG_IPV4));
-echo "Done\n";
-?>
---EXPECT--
-string(11) "192.168.0.1"
-NULL
-string(3) "::1"
-string(7) "fe00::0"
-NULL
-NULL
-string(9) "127.0.0.1"
-NULL
-string(12) "192.0.34.166"
-string(9) "127.0.0.1"
-string(9) "192.0.0.1"
-string(12) "192.0.34.166"
-NULL
-string(15) "255.255.255.255"
-NULL
-NULL
-NULL
-NULL
-NULL
-string(3) "::1"
-string(9) "127.0.0.1"
-Done
View
20 ext/filter/tests/019.phpt
@@ -1,20 +0,0 @@
---TEST--
-filter_data() & FL_IP and weird data
---FILE--
-<?php
-
-var_dump(filter_data("....", FL_IP));
-var_dump(filter_data("...", FL_IP));
-var_dump(filter_data("..", FL_IP));
-var_dump(filter_data(".", FL_IP));
-var_dump(filter_data("1.1.1.1", FL_IP));
-
-echo "Done\n";
-?>
---EXPECTF--
-NULL
-NULL
-NULL
-NULL
-string(7) "1.1.1.1"
-Done
View
18 ext/filter/tests/020.phpt
@@ -1,18 +0,0 @@
---TEST--
-filter_data() and FS_MAGIC_QUOTES
---FILE--
-<?php
-
-var_dump(filter_data("test'asd'asd'' asd\'\"asdfasdf", FS_MAGIC_QUOTES));
-var_dump(filter_data("'", FS_MAGIC_QUOTES));
-var_dump(filter_data("", FS_MAGIC_QUOTES));
-var_dump(filter_data(-1, FS_MAGIC_QUOTES));
-
-echo "Done\n";
-?>
---EXPECT--
-string(36) "test\'asd\'asd\'\' asd\\\'\"asdfasdf"
-string(2) "\'"
-string(0) ""
-string(2) "-1"
-Done
View
44 ext/filter/tests/021.phpt
@@ -1,44 +0,0 @@
---TEST--
-filter_data() and FS_NUMBER_*
---FILE--
-<?php
-
-var_dump(filter_data("qwertyu123456dfghj", FS_NUMBER_INT));
-var_dump(filter_data("asd123123.asd123.23", FS_NUMBER_INT));
-var_dump(filter_data("123,23", FS_NUMBER_INT));
-var_dump(filter_data("", FS_NUMBER_INT));
-var_dump(filter_data("0", FS_NUMBER_INT));
-var_dump(filter_data("asd123.2asd", FS_NUMBER_INT));
-var_dump(filter_data("qwertyuiop", FS_NUMBER_INT));
-var_dump(filter_data("123.4", FS_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-var_dump(filter_data("123,4", FS_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-var_dump(filter_data("123.4", FS_NUMBER_FLOAT, FILTER_FLAG_ALLOW_THOUSAND));
-var_dump(filter_data("123,4", FS_NUMBER_FLOAT, FILTER_FLAG_ALLOW_THOUSAND));
-var_dump(filter_data("123.4e", FS_NUMBER_FLOAT, FILTER_FLAG_ALLOW_SCIENTIFIC));
-var_dump(filter_data("123,4E", FS_NUMBER_FLOAT, FILTER_FLAG_ALLOW_SCIENTIFIC));
-var_dump(filter_data("qwe123,4qwe", FS_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-var_dump(filter_data("werty65456.34", FS_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-var_dump(filter_data("234.56fsfd", FS_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-var_dump(filter_data("", FS_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
-
-echo "Done\n";
-?>
---EXPECT--
-string(6) "123456"
-string(11) "12312312323"
-string(5) "12323"
-string(0) ""
-string(1) "0"
-string(4) "1232"
-string(0) ""
-string(5) "123.4"
-string(4) "1234"
-string(4) "1234"
-string(5) "123,4"
-string(5) "1234e"
-string(5) "1234E"
-string(4) "1234"
-string(8) "65456.34"
-string(6) "234.56"
-string(0) ""
-Done
View
20 ext/filter/tests/022.phpt
@@ -1,20 +0,0 @@
---TEST--
-filter_data() and FS_EMAIL
---FILE--
-<?php
-
-var_dump(filter_data("a@b.c", FS_EMAIL));
-var_dump(filter_data("a[!@#$%^&*()@a@#$%^&*(.com@#$%^&*(", FS_EMAIL));
-var_dump(filter_data("white space here \ \ \" som more", FS_EMAIL));
-var_dump(filter_data("", FS_EMAIL));
-var_dump(filter_data("123456789000000", FS_EMAIL));
-
-echo "Done\n";
-?>
---EXPECTF--
-string(5) "a@b.c"
-string(30) "a[!@#$%^&*@a@#$%^&*.com@#$%^&*"
-string(21) "whitespaceheresommore"
-string(0) ""
-string(15) "123456789000000"
-Done
View
20 ext/filter/tests/023.phpt
@@ -1,20 +0,0 @@
---TEST--
-filter_data() and FS_UNSAFE_RAW
---FILE--
-<?php
-
-var_dump(filter_data("}\"<p>test para</p>", FS_UNSAFE_RAW, FILTER_FLAG_ENCODE_AMP));
-var_dump(filter_data("a[!@#<b>$%^&*()@a@#$%^&*(.<br>com@#$%^&*(", FS_UNSAFE_RAW, FILTER_FLAG_ENCODE_AMP));
-var_dump(filter_data("white space here \ \ \" some more", FS_UNSAFE_RAW, FILTER_FLAG_ENCODE_AMP));
-var_dump(filter_data("", FS_UNSAFE_RAW, FILTER_FLAG_ENCODE_AMP));
-var_dump(filter_data(" 123456789000000 <qwertyuiop> ", FS_UNSAFE_RAW, FILTER_FLAG_ENCODE_AMP));
-
-echo "Done\n";
-?>
---EXPECT--
-string(18) "}"<p>test para</p>"
-string(53) "a[!@#<b>$%^&#38;*()@a@#$%^&#38;*(.<br>com@#$%^&#38;*("
-string(32) "white space here \ \ " some more"
-string(0) ""
-string(48) " 123456789000000 <qwertyuiop> "
-Done
View
18 ext/filter/tests/024.phpt
@@ -1,18 +0,0 @@
---TEST--
-filter_data() and FS_ENCODED