$this->matches($request->getUri()->getHost()) ? $nextHandler($request, $options) : new RejectedPromise(sprintf( 'Requested host \'%s\' is not allowed in $GLOBALS[\'TYPO3_CONF_VARS\'][\'HTTP\'][\'allowed_hosts\'][\'%s\']', $request->getUri()->getHost(), $this->context )); } private function matches(string $host): bool { foreach ($this->allowedHosts as $allowedHost) { // Match wildcards if (str_contains($allowedHost, '*')) { $expr = implode( '.+', array_map( static fn(string $part): string => preg_quote($part, '/'), explode('*', $allowedHost) ) ); if (preg_match('/^' . $expr . '$/', $host)) { return true; } } elseif ($allowedHost === $host) { // Exact matches return true; } } return false; } }