开发者

safe php template engine

开发者 https://www.devze.com 2023-01-13 06:15 出处:网络
I finding a php template engine allow user defined function only or it allow white-list functions only. My problem is I will let my user edit their templates. So I need a开发者_运维知识库 safe templat

I finding a php template engine allow user defined function only or it allow white-list functions only. My problem is I will let my user edit their templates. So I need a开发者_运维知识库 safe template engine.


The twig project ( http://www.twig-project.org/ ) has a sandbox mode.


Rain implements the sandbox with black_list, if you ask they might add the white list as well http://www.raintpl.com/


If you just need conditions(if), loops(for) and filters maybe my minimal Text-Template class could do the job: https://github.com/dermatthes/text-template

It's pure regular expressions without the need for filesystem access nor eval()'d code. So it should be quite secure. And it'll parse 50kB of template within <3ms.

0

精彩评论

暂无评论...
验证码 换一张
取 消