当前位置:网站首页>thinkphp框架5.0.23安全更新问题-漏洞修复-/thinkphp/library/think/App.php具体怎么改以及为什么要这么改
thinkphp框架5.0.23安全更新问题-漏洞修复-/thinkphp/library/think/App.php具体怎么改以及为什么要这么改
2022-08-02 18:40:00 【~央千澈~】
官方原文问答那稍微有点乱,给大家整理下 /thinkphp/library/think/App.php 文件第553行下方

// 当前模块路径
App::$modulePath = APP_PATH . ($module ? $module . DS : '');
// 是否自动转换控制器和操作名
$convert = is_bool($convert) ? $convert : $config['url_convert'];
// 获取控制器名
$controller = strip_tags($result[1] ?: $config['default_controller']);
if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) {
throw new HttpException(404, 'controller not exists:' . $controller);
}
在获取控制器下方加入
if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) {
throw new HttpException(404, 'controller not exists:' . $controller);
}我们看了需要这样加,那么为什么需要这样加?
preg_match() 函数用于进行正则表达式匹配,成功返回 1 ,否则返回 0 。
preg_match() 匹配成功一次后就会停止匹配,如果要实现全部结果的匹配,则需使用 preg_match_all() 函数
你上面的if判断$name 是匹配汉字,就是用正则表达式判断输入的姓名是否是汉字
而if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)判断得到的控制器名$control是否属于/^[A-Za-z](\w|\.)*$/
/^$/ 代表正则的头和尾, [a-zA-Z]表示大小写的a到z的字母,后面的*号表示匹配0个或多个字符,
如果属于那么则抛出新的函数, throw new HttpException, 404并且提示controller not exists
解决方案参考文:
边栏推荐
- 安装Mac版Mysql卡在Installation阶段,彻底清理mysql并重装mysql
- 连续三次 | 灵雀云入选Gartner中国ICT技术成熟度曲线报告
- 流量分析三—远程登陆
- 衡量软件产品质量的 14 个指标
- What skills are the most practical for college students in communications?
- 3 and a half years of testing experience, I don't have 20K, it seems it's time to change jobs
- VSTO踩坑记录(1)- 从零开始开发outlook插件
- NIO's Selector execution process
- How to deal with security risks posed by machine identities
- TSF微服务治理实战系列(一)——治理蓝图
猜你喜欢
随机推荐
ROS基本编程概述
AI智能剪辑,仅需2秒一键提取精彩片段
视频隐写一
3 and a half years of testing experience, I don't have 20K, it seems it's time to change jobs
leetcode:622. 设计循环队列【循环队列板子】
平稳发展 | 西欧地区手游玩家的数据和洞察
LeetCode 2349. 设计数字容器系统(SortedSet)
“12306”的架构到底有多牛逼?
如何获取EasyCVR平台设备通道的RTMP视频流地址?
读书笔记之《你想过怎样的一生?》
喜迎八一 《社会企业开展应聘文职人员培训规范》团体标准出版发行会暨橄榄枝大课堂上线发布会在北京举行
MYSQL关键字执行顺序?
register和volatile的区别
NIO基础之三大组件
【动态规划专项训练】基础篇
AtomicInteger详解
看【C语言】实现简易计算器教程,让小伙伴们为你竖起大拇指
Mobile Banking Experience Test: How to Get the Real User Experience
中断向量表概述
[深入研究4G/5G/6G专题-49]: 5G Link Adaption链路自适应-5-上行链路自适应ULLA-PUSCH信道








