chregu Wed Apr 6 08:26:30 2005 EDT
Modified files:
/php-src NEWS
/php-src/ext/xsl php_xsl.c php_xsl.h xsltprocessor.c
Log:
- Added optional first parameter to XsltProcessor::registerPHPFunctions to
only
allow certain functions to be called from XSLT.
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1864&r2=1.1865&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1864 php-src/NEWS:1.1865
--- php-src/NEWS:1.1864 Mon Apr 4 10:59:38 2005
+++ php-src/NEWS Wed Apr 6 08:26:29 2005
@@ -28,6 +28,8 @@
. added spl_autoload*() functions
. converted several 5.0 examples into c code
. added class File
+- Added optional first parameter to XsltProcessor::registerPHPFunctions to
only
+ allow certain functions to be called from XSLT. (Christian)
- Added the ability to override the autotools executables used by the buildconf
script via the PHP_AUTOCONF and PHP_AUTOHEADER environmental variables. (Jon)
- Added several new functions to support the PostgreSQL v3 protocol introduced
http://cvs.php.net/diff.php/php-src/ext/xsl/php_xsl.c?r1=1.28&r2=1.29&ty=u
Index: php-src/ext/xsl/php_xsl.c
diff -u php-src/ext/xsl/php_xsl.c:1.28 php-src/ext/xsl/php_xsl.c:1.29
--- php-src/ext/xsl/php_xsl.c:1.28 Wed Mar 2 13:27:25 2005
+++ php-src/ext/xsl/php_xsl.c Wed Apr 6 08:26:29 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_xsl.c,v 1.28 2005/03/02 18:27:25 rrichards Exp $ */
+/* $Id: php_xsl.c,v 1.29 2005/04/06 12:26:29 chregu Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -78,6 +78,9 @@
zend_hash_destroy(intern->parameter);
FREE_HASHTABLE(intern->parameter);
+ zend_hash_destroy(intern->registered_phpfunctions);
+ FREE_HASHTABLE(intern->registered_phpfunctions);
+
if (intern->node_list) {
zend_hash_destroy(intern->node_list);
FREE_HASHTABLE(intern->node_list);
@@ -116,6 +119,7 @@
intern->parameter = NULL;
intern->hasKeys = 0;
intern->registerPhpFunctions = 0;
+ intern->registered_phpfunctions = NULL;
intern->node_list = NULL;
intern->doc = NULL;
@@ -124,6 +128,8 @@
zend_hash_copy(intern->std.properties, &class_type->default_properties,
(copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
ALLOC_HASHTABLE(intern->parameter);
zend_hash_init(intern->parameter, 0, NULL, ZVAL_PTR_DTOR, 0);
+ ALLOC_HASHTABLE(intern->registered_phpfunctions);
+ zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR,
0);
retval.handle = zend_objects_store_put(intern, NULL,
(zend_objects_free_object_storage_t) xsl_objects_free_storage, NULL TSRMLS_CC);
intern->handle = retval.handle;
retval.handlers = &xsl_object_handlers;
http://cvs.php.net/diff.php/php-src/ext/xsl/php_xsl.h?r1=1.13&r2=1.14&ty=u
Index: php-src/ext/xsl/php_xsl.h
diff -u php-src/ext/xsl/php_xsl.h:1.13 php-src/ext/xsl/php_xsl.h:1.14
--- php-src/ext/xsl/php_xsl.h:1.13 Wed Mar 2 13:27:25 2005
+++ php-src/ext/xsl/php_xsl.h Wed Apr 6 08:26:29 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_xsl.h,v 1.13 2005/03/02 18:27:25 rrichards Exp $ */
+/* $Id: php_xsl.h,v 1.14 2005/04/06 12:26:29 chregu Exp $ */
#ifndef PHP_XSL_H
#define PHP_XSL_H
@@ -57,6 +57,7 @@
HashTable *parameter;
int hasKeys;
int registerPhpFunctions;
+ HashTable *registered_phpfunctions;
HashTable *node_list;
php_libxml_node_object *doc;
} xsl_object;
http://cvs.php.net/diff.php/php-src/ext/xsl/xsltprocessor.c?r1=1.36&r2=1.37&ty=u
Index: php-src/ext/xsl/xsltprocessor.c
diff -u php-src/ext/xsl/xsltprocessor.c:1.36
php-src/ext/xsl/xsltprocessor.c:1.37
--- php-src/ext/xsl/xsltprocessor.c:1.36 Wed Mar 2 13:27:25 2005
+++ php-src/ext/xsl/xsltprocessor.c Wed Apr 6 08:26:29 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xsltprocessor.c,v 1.36 2005/03/02 18:27:25 rrichards Exp $ */
+/* $Id: xsltprocessor.c,v 1.37 2005/04/06 12:26:29 chregu Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -267,6 +267,10 @@
if (!zend_make_callable(&handler, &callable TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call
handler %s()", callable);
+ } else if ( intern->registerPhpFunctions == 2 &&
zend_hash_exists(intern->registered_phpfunctions, callable, strlen(callable) +
1) == 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not allowed to
call handler '%s()'.", callable);
+ // Push an empty string, so that we at least have an xslt
result...
+ valuePush(ctxt, xmlXPathNewString(""));
} else {
result = zend_call_function(&fci, NULL TSRMLS_CC);
if (result == FAILURE) {
@@ -685,13 +689,43 @@
{
zval *id;
xsl_object *intern;
+ zval *array_value, **entry, *new_string;
+ int name_len = 0;
+ char *name;
DOM_GET_THIS(id);
- intern = (xsl_object *)zend_object_store_get_object(id TSRMLS_CC);
- intern->registerPhpFunctions = 1;
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS()
TSRMLS_CC, "a", &array_value) == SUCCESS) {
+ intern = (xsl_object *)zend_object_store_get_object(id
TSRMLS_CC);
+ zend_hash_internal_pointer_reset(Z_ARRVAL_P(array_value));
+ while (zend_hash_get_current_data(Z_ARRVAL_P(array_value),
(void **)&entry) == SUCCESS) {
+ SEPARATE_ZVAL(entry);
+ convert_to_string_ex(entry);
+
+ MAKE_STD_ZVAL(new_string);
+ ZVAL_LONG(new_string,1);
+
+ zend_hash_update(intern->registered_phpfunctions,
Z_STRVAL_PP(entry), Z_STRLEN_PP(entry) + 1, &new_string, sizeof(zval*), NULL);
+ zend_hash_move_forward(Z_ARRVAL_P(array_value));
+ }
+ intern->registerPhpFunctions = 2;
+ RETURN_TRUE;
+
+ } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == SUCCESS) {
+ intern = (xsl_object *)zend_object_store_get_object(id
TSRMLS_CC);
+
+ MAKE_STD_ZVAL(new_string);
+ ZVAL_LONG(new_string,1);
+ zend_hash_update(intern->registered_phpfunctions, name,
name_len + 1, &new_string, sizeof(zval*), NULL);
+ intern->registerPhpFunctions = 2;
+
+ } else {
+ intern = (xsl_object *)zend_object_store_get_object(id
TSRMLS_CC);
+ intern->registerPhpFunctions = 1;
+ }
+
}
/* }}} end xsl_xsltprocessor_register_php_functions(); */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php