Issue Bug Under Review

#111145Non-UTF-8 characters in URI path leading to NullSite Object

Lukas Witten 10/19/26, 10:10 updated 11/09/26, 20:39

Description

Description

If the URI path contains percent-encoded bytes that aren’t valid UTF-8 (e.g. ISO 8859-1), TYPO3 doesn’t resolve any site, even if the host matches a site’s base. The request ends up with a NullSite Object.

Reproduce

“https://example.org/%F6” would end up on TYPO3’s generic “Page Not Found” page(Reason: No site configuration found.), instead of your configured Error-Handling, since the Site Object could’nt be resolved.

Expected behaviour

Non-UTF-8 characters in the URI path don’t influence if a site is resolved or not.

Failing Line

vendor/typo3/cms-core/Classes/Routing/SiteMatcher.php line 244

$match = $matcher->match($uri->getPath());

Possible Fix

Before matching, replace invalid UTF-8 byte sequences in the path.

$match = $matcher->match($this->sanitizePath($uri->getPath()));

protected function sanitizePath(string $path): string
{
    if (mb_check_encoding(rawurldecode($path), 'UTF-8')) {
        return $path;
    }
    return implode('/', array_map(
        static fn(string $segment): string => rawurlencode(mb_scrub(rawurldecode($segment), 'UTF-8')),
        explode('/', $path)
    ));
}

Reviews 1

History 12