Skip to content

Commit 802f284

Browse files
committed
修正控制器调用
1 parent 4c2b06e commit 802f284

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

library/think/route/dispatch/Module.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ public function init()
6767
// 是否自动转换控制器和操作名
6868
$convert = is_bool($this->convert) ? $this->convert : $this->rule->getConfig('url_convert');
6969
// 获取控制器名
70-
$controller = strip_tags($result[1] ?: $this->rule->getConfig('default_controller'));
70+
$controller = strip_tags($result[1] ?: $this->rule->getConfig('default_controller'));
71+
72+
if (!preg_match('/^[A-Za-z](\w)*$/', $controller)) {
73+
throw new HttpException(404, 'controller not exists:' . $controller);
74+
}
75+
7176
$this->controller = $convert ? strtolower($controller) : $controller;
7277

7378
// 获取操作名

0 commit comments

Comments
 (0)