From ab7c3a71a46af9873389b9c52e4459bbd7bfbf93 Mon Sep 17 00:00:00 2001 From: xiaomlove <1939737565@qq.com> Date: Sun, 9 Nov 2025 13:30:14 +0700 Subject: [PATCH] fix filter_src() undefined HTTP_HOST --- include/globalfunctions.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/globalfunctions.php b/include/globalfunctions.php index 3cb9de6a..8b2e2b52 100644 --- a/include/globalfunctions.php +++ b/include/globalfunctions.php @@ -507,7 +507,7 @@ function isHttps(): bool } -function getSchemeAndHttpHost(bool $fromConfig = false) +function getSchemeAndHttpHost(bool $fromConfig = false): string { if (isRunningInConsole() || $fromConfig) { $host = get_setting("basic.BASEURL"); @@ -1378,12 +1378,15 @@ function filter_src($src) return $src; } $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; } - $guessScriptFilename = sprintf("%s/%s", $_SERVER['DOCUMENT_ROOT'], trim($path, '/')); - if (!file_exists($guessScriptFilename)) { - return $src; + if (isset($_SERVER['DOCUMENT_ROOT'])) { + $guessScriptFilename = sprintf("%s/%s", $_SERVER['DOCUMENT_ROOT'], trim($path, '/')); + if (!file_exists($guessScriptFilename)) { + return $src; + } } //only allow these $imgExtensions = implode("|", \App\Models\Attachment::IMG_EXTENSIONS);