Restricting PHP Function Calls from XSLT

王朝php·作者佚名  2006-01-09
宽屏版  字体: |||超大  

A quick post from Christian Stocker shows you how to only allow certain PHP functions to be called from within PHP

I just committed a patch to the xsl-extension of PHP, which makes it possible to only allow certain PHP functions to be called from within PHP. While registerPHPFunctions is (IMHO) a cool and useful feature, it can be pretty dangerous if your XSLT stylesheets do not come from a totally trusted source. But now in PHP 5.1 you will be able to define, which functions are allowed, for example

$xsl->registerPHPFunctions(array("date","time"));

would allow only the date and time function. You can also define static methods like "MyClass::MyMethod". Calling the method multiple times will add those functions to the allowed list, not remove the old ones. And calling it without parameter just allows everything like in PHP 5.0. You can also give a string instead of an array, if you just want to add one function to the list.

And here's the patch against PHP_5_0, if you want to use it on the 5.0 branch.

For more information visit: http://blog.bitflux.ch/

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有