[PHP] PHP7已经删除了preg_replace的e修饰符
官网提示是这样的,对/e修饰符的支持已删除。请改用preg_replace_callback()
原因是/e 修正符使 preg_replace() 将 replacement 参数当作 PHP 代码(在适当的逆向引用替换完之后),会被一句话后门使用
看看smarty中是也是这样用的,也是存在问题
$source_content = preg_replace($search.'e', "'"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "'"
, $source_content);
可以把smarty模板修改成这个
$source_content = preg_replace_callback($search, function ($matches){
$str="";
$str.=$this->_quote_replace($this->left_delimiter) . 'php';
$str.=str_repeat("\\n\\", substr_count($matches[1], "\\n\\"));
$str.=$this->_quote_replace($this->right_delimiter);
return $str;
}, $source_content);
最新文章
- C#判断数组是否为空
- Django url()函数详解
- ORA-00245: control file backup failed; target is likely on a local file system
- win32_11gR2_database安装教程
- [AngularJS] Directive with Transcluded Elements
- MSSQL Server 导入/导出到远程服务器
- ibatis集成Sqlite:小数据库也有大作用
- vs 自动生成core dump文件
- SQL学习之高级联结(自联结、自然联结、外联接)
- Kotlin初探
- 算法题丨Longest Consecutive Sequence
- react-native-deprecated-custom-components
- Appium移动自动化测试入门及简单实例(python)
- XML部分
- apicloud 自定义模块引用aar
- js中表单数据序列化方式
- How to Pronounce the I in ING
- JavaScript周报#184
- Fiddler Web Session 列表(1)
- Eclipse开发Java程序入门,HelloWord