当前位置:网站首页>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
解决方案参考文:
边栏推荐
- 请教下,1.0.0和1.0.2的底层数据库表结构有变化吗?
- 连续三次 | 灵雀云入选Gartner中国ICT技术成熟度曲线报告
- 固态硬盘接口类型介绍
- 洛谷P4799 世界冰球锦标赛
- 3年半测试经验,20K我都没有,看来是时候跳槽了
- Openharmony - 基于ArkUI(TS)开发颜色选择器
- 【C语言刷题】双指针原地修改数组(力扣原题分析)
- selenium installation and environment configuration firefox
- cache2go-源码阅读
- I have 8 years of experience in the Ali test, and I was able to survive by relying on this understanding.
猜你喜欢
随机推荐
Technical life | How to draw a big picture of business
Win11dll文件缺失怎么修复?Win11系统dll文件丢失的解决方法
Sentinel vs Hystrix 限流对比,到底怎么选?
流量分析四—蓝牙
洛谷P1966 火柴排队
sed 命令
【动态规划专项训练】基础篇
Mobile Banking Experience Test: How to Get the Real User Experience
Three components of NIO foundation
监控易火星版即将亮相:分布式运维帮助TOP3000大企业跨越管理鸿沟
How to build a quasi-real-time data warehouse?
“12306”的架构到底有多牛逼?
AI智能剪辑,仅需2秒一键提取精彩片段
洛谷P2574 XOR的艺术
mongodb的游标
读书笔记之《你想过怎样的一生?》
LeetCode 2353. 设计食物评分系统(sortedcontainers)
Openharmony - 基于ArkUI(TS)开发颜色选择器
7.23 - 每日一题 - 408
【C语言刷题】牛客JZ65——不用四则运算作加法