优化url检测

pull/446/head
Karson 2023-06-16 17:45:07 +08:00
parent d2c275e20a
commit dc466cb1c9
1 changed files with 2 additions and 2 deletions

View File

@ -520,8 +520,8 @@ if (!function_exists('check_url_allowed')) {
//如果是站外链接则需要判断HOST是否允许 //如果是站外链接则需要判断HOST是否允许
if (preg_match("/((http[s]?:\/\/)+(?>[a-z\-0-9]{2,}\.){1,}[a-z]{2,8})(?:\s|\/)/i", $url)) { if (preg_match("/((http[s]?:\/\/)+(?>[a-z\-0-9]{2,}\.){1,}[a-z]{2,8})(?:\s|\/)/i", $url)) {
$chkHost = parse_url(strtolower($url), PHP_URL_HOST);
if (in_array(strtolower(parse_url($url, PHP_URL_HOST)), $allowedHostArr)) { if ($chkHost && in_array($chkHost, $allowedHostArr)) {
return true; return true;
} }
} }