Skip to content

Commit 7ea1820

Browse files
committed
更新核心框架
1 parent 4702d52 commit 7ea1820

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

wwwroot/ThinkPHP/Common/functions.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ function I($name,$default='',$filter=null,$datas=null) {
341341
}else{ // 变量默认值
342342
$data = isset($default)?$default:NULL;
343343
}
344+
is_array($data) && array_walk_recursive($data,'think_filter');
344345
return $data;
345346
}
346347

@@ -1471,3 +1472,12 @@ function send_http_status($code) {
14711472
function in_array_case($value,$array){
14721473
return in_array(strtolower($value),array_map('strtolower',$array));
14731474
}
1475+
1476+
function think_filter(&$value){
1477+
// TODO 其他安全过滤
1478+
1479+
// 过滤查询特殊字符
1480+
if(preg_match('/^(EXP|NEQ|GT|EGT|LT|ELT|OR|LIKE|NOTLIKE|BETWEEN|IN)$/i',$value)){
1481+
$value .= ' ';
1482+
}
1483+
}

wwwroot/ThinkPHP/Library/Think/App.class.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ static public function init() {
3434
// URL调度
3535
Dispatcher::dispatch();
3636

37+
if(C('REQUEST_VARS_FILTER')){
38+
// 全局安全过滤
39+
array_walk_recursive($_GET, 'think_filter');
40+
array_walk_recursive($_POST, 'think_filter');
41+
array_walk_recursive($_REQUEST, 'think_filter');
42+
}
43+
3744
// URL调度结束标签
3845
Hook::listen('url_dispatch');
3946

@@ -150,6 +157,7 @@ static public function exec() {
150157
}
151158
}
152159
}
160+
array_walk_recursive($args,'think_filter');
153161
$method->invokeArgs($module,$args);
154162
}else{
155163
$method->invoke($module);

0 commit comments

Comments
 (0)