当前位置:网站首页>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
解决方案参考文:
边栏推荐
- Mobile Banking Experience Test: How to Get the Real User Experience
- Why young people are snapping up domestic iPhone, because it is much cheaper and more populist
- EasyCVR平台通过国标GB28181接入柯达NVR显示注册失败,该如何解决?
- 日常开发中,String类中常用的方法
- Boyun Selected as Gartner China DevOps Representative Vendor
- 淘宝|蚂蚁|菜鸟|盒马|嘀嘀|饿了么面经(已拿多个offer)
- WPF login with Prism
- LeetCode 2343. 裁剪数字后查询第 K 小的数字
- 新公链时代的跨链安全性解决方案
- LeetCode 2336. 无限集中的最小数字(SortedSet)
猜你喜欢
Interviewer: can you talk about optimistic locking and pessimistic locks

被审稿人吐槽没有novelty!深度学习方向怎么找创新点?

NIO之Selector执行流程

pydev debugger: warning: trying to add breakpoint to file that does not exist: /tmp/xxx

音频隐写一

中国科学院院属研究单位

Technical life | How to draw a big picture of business

实例033:列表转字符串

LeetCode 2353. 设计食物评分系统(sortedcontainers)

selenium安装和环境配置Firefox
随机推荐
7.24 - 每日一题 - 408
「日志」深度学习 CUDA环境配置
pydev debugger: warning: trying to add breakpoint to file that does not exist: /tmp/xxx
register和volatile的区别
Electronic Industry Inventory Management Pain Points and WMS Warehouse Management System Solutions
去年,一道蚂蚁金服笔试题,还行,中等难度
洛谷P2345 MooFest G
固态硬盘接口类型介绍
Interviewer: can you talk about optimistic locking and pessimistic locks
1.0.0到1.0.2的底层数据库表的更新,需要再重新自建数据库吗?
LeetCode 2349. 设计数字容器系统(SortedSet)
注释
洛谷P2574 XOR的艺术
论文阅读_胶囊网络CapsNet
开源一夏 | Web开发(七):登录实现及功能测试
ROS基本编程概述
How can services start smoothly under tens of millions of QPS
共享平台如何提高财务的分账记账效率?
【C语言刷题】Leetcode238——除自身以外数组的乘积
洛谷P1502 窗口的星星