mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
fix filter_src() undefined HTTP_HOST
This commit is contained in:
@@ -507,7 +507,7 @@ function isHttps(): bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getSchemeAndHttpHost(bool $fromConfig = false)
|
function getSchemeAndHttpHost(bool $fromConfig = false): string
|
||||||
{
|
{
|
||||||
if (isRunningInConsole() || $fromConfig) {
|
if (isRunningInConsole() || $fromConfig) {
|
||||||
$host = get_setting("basic.BASEURL");
|
$host = get_setting("basic.BASEURL");
|
||||||
@@ -1378,12 +1378,15 @@ function filter_src($src)
|
|||||||
return $src;
|
return $src;
|
||||||
}
|
}
|
||||||
$host = parse_url($src, PHP_URL_HOST);
|
$host = parse_url($src, PHP_URL_HOST);
|
||||||
if (!empty($host) && $host != $_SERVER['HTTP_HOST']) {
|
$currentHost = parse_url(getSchemeAndHttpHost(), PHP_URL_HOST);
|
||||||
|
if (!empty($host) && $host != $currentHost) {
|
||||||
return $src;
|
return $src;
|
||||||
}
|
}
|
||||||
$guessScriptFilename = sprintf("%s/%s", $_SERVER['DOCUMENT_ROOT'], trim($path, '/'));
|
if (isset($_SERVER['DOCUMENT_ROOT'])) {
|
||||||
if (!file_exists($guessScriptFilename)) {
|
$guessScriptFilename = sprintf("%s/%s", $_SERVER['DOCUMENT_ROOT'], trim($path, '/'));
|
||||||
return $src;
|
if (!file_exists($guessScriptFilename)) {
|
||||||
|
return $src;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//only allow these
|
//only allow these
|
||||||
$imgExtensions = implode("|", \App\Models\Attachment::IMG_EXTENSIONS);
|
$imgExtensions = implode("|", \App\Models\Attachment::IMG_EXTENSIONS);
|
||||||
|
|||||||
Reference in New Issue
Block a user