优化接口以及后台页面样式
This commit is contained in:
@@ -115,6 +115,24 @@ class Auth extends Api
|
||||
}
|
||||
|
||||
$username = trim(strval($request->get('username', $request->post('username', ''))));
|
||||
// 兼容:querystring 中未编码的 '+' 会被解析为空格(application/x-www-form-urlencoded 规则)
|
||||
// 例如:/api/v1/temLogin?username=+607... 期望保留 '+',则从原始 querystring 提取并还原
|
||||
if ($username !== '' && str_contains($username, ' ')) {
|
||||
$qs = $request->queryString();
|
||||
if (is_string($qs) && $qs !== '') {
|
||||
foreach (explode('&', $qs) as $pair) {
|
||||
if ($pair === '' || !str_contains($pair, '=')) {
|
||||
continue;
|
||||
}
|
||||
[$k, $v] = explode('=', $pair, 2);
|
||||
if (rawurldecode($k) === 'username') {
|
||||
// 先把 %xx 解码;注意这里不把 '+' 当空格处理,从而保留 '+'
|
||||
$username = trim(rawurldecode($v));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($username === '') {
|
||||
return $this->error(__('Parameter username can not be empty'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user