[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);
[PHP] PHP7已经删除了preg_replace的e修饰符的更多相关文章
- 正则表达式preg_replace中危险的/e修饰符带来的安全漏洞问题
mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit]) /e 修饰符使 preg_rep ...
- 慎用preg_replace危险的/e修饰符(一句话后门常用)
要确保 replacement 构成一个合法的 PHP 代码字符串,否则 PHP 会在报告在包含 preg_replace() 的行中出现语法解析错误 preg_replace函数原型: mi ...
- php新版本废弃 preg_replace /e 修饰符
php新版本废弃 preg_replace /e 修饰符 分类: PHP -- : 3531人阅读 评论() 收藏 举报 php正则 最近服务器php版本升级到了 5.6 发现出了很多警告 [php] ...
- php新版本号废弃 preg_replace /e 修饰符
近期serverphp版本号升级到了 5.6 发现出了非常多警告 preg_replace(): The /e modifier is deprecated, use preg_replace_ca ...
- 关于thinkhphp3.1中废弃 preg_replace /e 修饰符
警告:preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead 网上查了下 发现 php5.5版 ...
- preg_replace($pattern, $replacement, $content) 修饰符的奇葩作用
$str = "<span>lin</span> == <span>3615</span>";$pattern = "/& ...
- preg_replace修饰符e的用法
$tmp_refer = postget('refer');$tmp_refer = preg_replace("/tn-(.*?).html/ies", "'tn-'. ...
- XCTF-ics-05(文件包含+preg_replace函数/e修正符下的代码执行漏洞)
记一道preg_replace函数/e模式下的代码执行漏洞利用的题. 只有设备维护中心页面可以进入,页面没有什么可点击的,查看源代码,发现这里有个参数. 拼接到url,页面显示index,拼接/etc ...
- PHP7和PHP5在安全上的区别[更新]
0X01 前言 本篇文章大多为转载,但是修正了一些不正确的说法,对某些功能点的变更指出具体是哪个版本变更,加入了一些小更新. (原文地址:https://www.freebuf.com/article ...
随机推荐
- PTA的Python练习题(十六)
第4章-15 换硬币 挺难的,这里学到一个range的用法: 也就是说range函数能实现顺序和倒序,取决于step是正是负 count = 0 x = int(input()) a = x // 5 ...
- 吴裕雄 python 机器学习——模型选择参数优化暴力搜索寻优GridSearchCV模型
import scipy from sklearn.datasets import load_digits from sklearn.metrics import classification_rep ...
- java8中的常用日期操作
java8有很多时间上的新api,在操作时间的时候很好用,这儿算是个备忘录吧,(补充中...) 定位某个时间:of方法 LocalDateTime dateTime = LocalDateTime.o ...
- mui 获取本地APP本版号的两种方式
第一种 mui.plusReady(function () { mui.getJSON("manifest.json", null, function (data) { vum = ...
- Centos7 安装virtualenv bash: virtualenv: command not found...的解决
安装好了python3的环境前提下 1.使用pip3安装virtualenv pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple virt ...
- ANSYS热分析简介1
目录 1. ANSYS热分析简介 1.1 传导 1.2 热载荷分类 1.2.1 载荷施加 1.3 热分析分类 1.3.1 稳态热分析 1.3.2 瞬态热分析 1.3.3 非线性分析综述 2. 热分析单 ...
- java代码开启关闭线程(nginx)
源码: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; pub ...
- wx小程序笔记
目录 p18 事件绑定1 p19 事件绑定2 btn p20+ view 相关,wxss,less,css 零基础玩转微信小程序[黑马程序员] https://www.bilibili.com/vid ...
- LeetCode简单题(四)
题目一: 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格. 设计一个算法来计算你所能获取的最大利润.你可以尽可能地完成更多的交易(多次买卖一支股票). 注意:你不能同时参与多笔交易(你 ...
- pip源、搭建虚拟环境、git
一.pip源 1.1 介绍 1.采用国内源,加速下载模块的速度2.常用pip源:-- 豆瓣:https://pypi.douban.com/simple-- 阿里:https://mirrors.al ...