From: Alexander Ebert Date: Mon, 29 Jan 2024 17:37:37 +0000 (+0100) Subject: Fix the default hostname for links without hostnames X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7791ac854122d00c8e1c164cd0f006657dbd78d3;p=GitHub%2FWoltLab%2FWCF.git Fix the default hostname for links without hostnames See https://www.woltlab.com/community/thread/302070-link-ohne-protokoll-zeigt-auf-localhost/ --- diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeA.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeA.class.php index 3234761de4..e33f93706c 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeA.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeA.class.php @@ -66,6 +66,12 @@ class HtmlOutputNodeA extends AbstractHtmlOutputNode if ($href->getScheme() !== 'mailto') { if (ApplicationHandler::getInstance()->isInternalURL($href->__toString())) { + if ($href->getHost() === '') { + // `withScheme()` implicitly adds `localhost` + // https://www.woltlab.com/community/thread/302070-link-ohne-protokoll-zeigt-auf-localhost/ + $href = $href->withHost(ApplicationHandler::getInstance()->getDomainName()); + } + $href = $href->withScheme(RouteHandler::secureConnection() ? 'https' : 'http'); $element->setAttribute(