优化检测的URL默认值

pull/446/head
Karson 2023-06-16 17:37:34 +08:00
parent 3549e95ea1
commit d2c275e20a
1 changed files with 5 additions and 1 deletions

View File

@ -502,13 +502,17 @@ if (!function_exists('check_url_allowed')) {
* @param string $url URL
* @return bool
*/
function check_url_allowed($url = null)
function check_url_allowed($url = '')
{
//允许的主机列表
$allowedHostArr = [
strtolower(request()->host())
];
if (empty($url)) {
return true;
}
//如果是站内相对链接则允许
if (preg_match("/^[\/a-z][a-z0-9][a-z0-9\.\/]+\$/i", $url) && substr($url, 0, 2) !== '//') {
return true;