Skip to content

Commit 608baa4

Browse files
author
SVN Migration
committed
This commit was manufactured by cvs2svn to create branch 'PHP_5_2'.
1 parent 55f0daf commit 608baa4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+5446
-0
lines changed

ext/filter/CREDITS

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Input Filter
2+
Rasmus Lerdorf, Derick Rethans

ext/filter/callback_filter.c

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP Version 5 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2006 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 3.01 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.php.net/license/3_01.txt |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| [email protected] so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Authors: Derick Rethans <[email protected]> |
16+
+----------------------------------------------------------------------+
17+
*/
18+
19+
/* $Id$ */
20+
21+
#include "php_filter.h"
22+
23+
void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL)
24+
{
25+
char *name = NULL;
26+
zval *retval_ptr;
27+
zval ***args;
28+
int status;
29+
30+
if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_CHECK_NO_ACCESS, &name)) {
31+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument is expected to be a valid callback");
32+
if (name) {
33+
efree(name);
34+
}
35+
zval_dtor(value);
36+
Z_TYPE_P(value) = IS_NULL;
37+
return;
38+
}
39+
efree(name);
40+
41+
args = safe_emalloc(sizeof(zval **), 1, 0);
42+
args[0] = &value;
43+
44+
status = call_user_function_ex(EG(function_table), NULL, option_array, &retval_ptr, 1, args, 0, NULL TSRMLS_CC);
45+
46+
if (status == SUCCESS && retval_ptr != NULL) {
47+
zval_dtor(value);
48+
*value = *retval_ptr;
49+
zval_copy_ctor(value);
50+
} else {
51+
zval_dtor(value);
52+
Z_TYPE_P(value) = IS_NULL;
53+
}
54+
55+
if (retval_ptr) {
56+
zval_ptr_dtor(&retval_ptr);
57+
}
58+
efree(args);
59+
}
60+
61+
/*
62+
* Local variables:
63+
* tab-width: 4
64+
* c-basic-offset: 4
65+
* End:
66+
* vim600: noet sw=4 ts=4 fdm=marker
67+
* vim<600: noet sw=4 ts=4
68+
*/

ext/filter/config.m4

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
dnl $Id$
2+
dnl config.m4 for input filtering extension
3+
4+
PHP_ARG_ENABLE(filter, whether to enable input filter support,
5+
[ --disable-filter Disable input filter support], yes)
6+
7+
PHP_ARG_WITH(pcre-dir, pcre install prefix,
8+
[ --with-pcre-dir FILTER: pcre install prefix], no, no)
9+
10+
if test "$PHP_FILTER" != "no"; then
11+
12+
dnl Check if configure is the PHP core configure
13+
if test -n "$PHP_VERSION"; then
14+
dnl This extension can not be build as shared when in PHP core
15+
ext_shared=no
16+
else
17+
dnl This is PECL build, check if bundled PCRE library is used
18+
old_CPPFLAGS=$CPPFLAGS
19+
CPPFLAGS=$INCLUDES
20+
AC_EGREP_CPP(yes,[
21+
#include <main/php_config.h>
22+
#if defined(HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
23+
yes
24+
#endif
25+
],[
26+
PHP_PCRE_REGEX=yes
27+
],[
28+
AC_EGREP_CPP(yes,[
29+
#include <main/php_config.h>
30+
#if defined(HAVE_PCRE) && !defined(COMPILE_DL_PCRE)
31+
yes
32+
#endif
33+
],[
34+
PHP_PCRE_REGEX=pecl
35+
],[
36+
PHP_PCRE_REGEX=no
37+
])
38+
])
39+
CPPFLAGS=$old_CPPFLAGS
40+
fi
41+
42+
if test "$PHP_PCRE_REGEX" != "yes"; then
43+
dnl
44+
dnl If PCRE extension is enabled we can use the already found paths,
45+
dnl otherwise we have to detect them here:
46+
dnl
47+
if test "$PHP_PCRE_REGEX" = "no" || test "$PHP_PCRE_REGEX" = "pecl"; then
48+
dnl Set the PCRE search dirs correctly
49+
case "$PHP_PCRE_DIR" in
50+
yes|no)
51+
PCRE_SEARCH_DIR="/usr/local /usr"
52+
;;
53+
*)
54+
PCRE_SEARCH_DIR="$PHP_PCRE_DIR"
55+
;;
56+
esac
57+
58+
for i in $PCRE_SEARCH_DIR; do
59+
if test -f $i/include/pcre/pcre.h; then
60+
PCRE_INCDIR=$i/include/pcre
61+
break
62+
elif test -f $i/include/pcre.h; then
63+
PCRE_INCDIR=$i/include
64+
break
65+
elif test -f $i/pcre.h; then
66+
PCRE_INCDIR=$i
67+
break
68+
fi
69+
done
70+
71+
if test -z "$PCRE_INCDIR"; then
72+
AC_MSG_ERROR([Could not find pcre.h anywhere under $PCRE_SEARCH_DIR])
73+
fi
74+
75+
for j in $PCRE_SEARCH_DIR/$PHP_LIBDIR $PCRE_SEARCH_DIR; do
76+
if test -f $j/libpcre.a || test -f $j/libpcre.$SHLIB_SUFFIX_NAME; then
77+
PCRE_LIBDIR=$j
78+
break
79+
fi
80+
done
81+
82+
if test -z "$PCRE_LIBDIR" ; then
83+
AC_MSG_ERROR([Could not find libpcre.(a|$SHLIB_SUFFIX_NAME) anywhere under $PCRE_SEARCH_DIR])
84+
fi
85+
fi
86+
87+
PHP_ADD_LIBRARY_WITH_PATH(pcre, $PCRE_LIBDIR, FILTER_SHARED_LIBADD)
88+
PHP_ADD_INCLUDE($PCRE_INCDIR)
89+
fi
90+
91+
PHP_NEW_EXTENSION(filter, filter.c sanitizing_filters.c logical_filters.c callback_filter.c, $ext_shared)
92+
PHP_SUBST(FILTER_SHARED_LIBADD)
93+
94+
PHP_INSTALL_HEADERS([$ext_srcdir/php_filter.h])
95+
fi

ext/filter/config.w32

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// $Id$
2+
// vim:ft=javascript
3+
4+
ARG_ENABLE("filter", "Filter Support", "yes");
5+
6+
if (PHP_FILTER == "yes") {
7+
EXTENSION("filter", "filter.c sanitizing_filters.c logical_filters.c callback_filter.c");
8+
}

0 commit comments

Comments
 (0)