<optiontype>boolean</optiontype>
<defaultvalue>1</defaultvalue>
</option>
+ <option name="internal_hostnames">
+ <categoryname>general.page</categoryname>
+ <optiontype>textarea</optiontype>
+ </option>
<option name="head_code">
<categoryname>general.page</categoryname>
<optiontype>textarea</optiontype>
</options>
</import>
<delete>
- <option name="http_enable_gzip" />
- <option name="meta_keywords" />
- <option name="register_admin_notification" />
- <option name="session_timeout" />
- <option name="session_validate_ip_address" />
- <option name="session_validate_user_agent" />
- <option name="session_enable_virtualization" />
- <option name="blacklist_hostnames" />
- <option name="module_user_cover_photo" />
+ <option name="http_enable_gzip"/>
+ <option name="meta_keywords"/>
+ <option name="register_admin_notification"/>
+ <option name="session_timeout"/>
+ <option name="session_validate_ip_address"/>
+ <option name="session_validate_user_agent"/>
+ <option name="session_enable_virtualization"/>
+ <option name="blacklist_hostnames"/>
+ <option name="module_user_cover_photo"/>
</delete>
</data>
\define('ENABLE_ENTERPRISE_MODE', 0);
\define('MESSAGE_ENABLE_USER_CONSENT', 1);
\define('MODIFICATION_LOG_EXPIRATION', 0);
+\define('INTERNAL_HOSTNAMES', '');
use wcf\data\package\Package;
use wcf\data\package\PackageList;
use wcf\system\cache\builder\ApplicationCacheBuilder;
-use wcf\system\Regex;
use wcf\system\request\RequestHandler;
use wcf\system\request\RouteHandler;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
+use wcf\util\ArrayUtil;
use wcf\util\FileUtil;
+use wcf\util\StringUtil;
+use wcf\util\Url;
/**
* Handles multi-application environments.
*/
public function isInternalURL($url)
{
- $protocolRegex = new Regex('^https(?=://)');
if (empty($this->pageURLs)) {
foreach ($this->getApplications() as $application) {
- $this->pageURLs[] = \preg_replace(
- '~/$~',
- '',
- $protocolRegex->replace(RouteHandler::getProtocol() . $application->domainName, 'http')
- );
+ $this->pageURLs[] = $application->domainName;
}
- $this->pageURLs = \array_unique($this->pageURLs);
- }
- foreach ($this->pageURLs as $pageURL) {
- if (\stripos($protocolRegex->replace($url, 'http'), $pageURL) === 0) {
- return true;
- }
+ $this->pageURLs = \array_unique(\array_merge(
+ $this->pageURLs,
+ ArrayUtil::trim(\explode("\n", StringUtil::unifyNewlines(\INTERNAL_HOSTNAMES)))
+ ));
}
- // relative urls contain no protocol, including implied
- if (!\preg_match('~^([a-zA-Z0-9]+)?://~', $url)) {
+ $host = Url::parse($url)['host'];
+
+ // Relative URLs are internal.
+ if (!$host) {
return true;
}
- return false;
+ return Url::getHostnameMatcher($this->pageURLs)($host);
}
/**
<item name="wcf.acp.option.message_enable_user_consent"><![CDATA[Inhalte von externen Anbietern erst nach Zustimmung anzeigen]]></item>
<item name="wcf.acp.option.modification_log_expiration"><![CDATA[Speicherzeit für Änderungen]]></item>
<item name="wcf.acp.option.modification_log_expiration.description"><![CDATA[Zeitraum, nachdem alte Änderungen aus dem Änderungsprotokoll entfernt werden [0, um die Entfernung gänzlich zu deaktivieren]]]></item>
+ <item name="wcf.acp.option.internal_hostnames"><![CDATA[Zusätzliche interne Domains]]></item>
+ <item name="wcf.acp.option.internal_hostnames.description"><![CDATA[Die aufgeführten Domains werden, neben den Domains der installierten Apps, als interne Domains angesehen. Der Abgleich erfolgt auf Basis der strikten Übereinstimmung, optional können Subdomains mit einem Platzhalter berücksichtigt werden: <kbd>*.example.com</kbd> umfasst sowohl <kbd>example.com</kbd> als auch Subdomains wie <kbd>foo.example.com</kbd> oder <kbd>www.example.com</kbd>.<br>Bitte nur eine Domain pro Zeile eingeben.]]></item>
</category>
<category name="wcf.acp.customOption">
<item name="wcf.acp.customOption.list"><![CDATA[Eingabefelder]]></item>
<item name="wcf.acp.option.message_enable_user_consent"><![CDATA[Prompt users before displaying content from external sources]]></item>
<item name="wcf.acp.option.modification_log_expiration"><![CDATA[Storage Time for Modification Logs]]></item>
<item name="wcf.acp.option.modification_log_expiration.description"><![CDATA[Modification logs will be deleted after the entered amount of days. To disable deleting old modification logs, enter “0”.]]></item>
+ <item name="wcf.acp.option.internal_hostnames"><![CDATA[Additional Internal Domains]]></item>
+ <item name="wcf.acp.option.internal_hostnames.description"><![CDATA[The listed domains will be considered as internal domains in addition to the domains in use by installed apps. Hostnames are exact matches only, a leading wildcard can be used to exclude an entire domain: <kbd>*.example.com</kbd> matches <kbd>example.com</kbd> and subdomains such as <kbd>foo.example.com</kbd> or <kbd>www.example.com</kbd>.<br>Enter one domain per line only.]]></item>
</category>
<category name="wcf.acp.customOption">
<item name="wcf.acp.customOption.list"><![CDATA[Option Fields]]></item>