Bug #93308
closedRouting with Chinese letters as language parameter does lead to 404
100%
Description
We have the following site configuration for Simplified Chinese:
title: 'Simplified Chinese' enabled: true base: /简/ typo3Language: cn locale: zh_CN.UTF-8 iso-639-1: zh navigationTitle: 简 hreflang: zh-Hans direction: ltr fallbackType: fallback fallbacks: '0' flag: cn languageId: '4' websiteTitle: ''
This configuration leads to a 404 error.
What happens¶
When a user navigates to a url including 简 as a language param, the path is automatically url encoded by the browser or the server (we use Nginx). In the `Request` object the sign becomes `%E7%AE%80`.
Middleware SiteResolver¶
This middleware tries to match the request url with the site configuration to get the correct site and language for the request.
SiteMatcher¶
It delegates the matching to `SiteMatcher::matchRequest()`. Within `SiteMatcher::getRouteCollectionForAllSites()` the site configuration is loaded from YAML and a `\TYPO3\CMS\Core\Routing\Route` is created from the routing settings. The `$path´ variable holds the decoded Chinese sign.
UrlMatcher¶
The method returns a collection of routes built from the site configuration, which gets passed to `Symfony\Component\Routing\Matcher\UrlMatcher::__construct()`. Right after that, `SiteMatcher` delegates the matching to `Symfony\Component\Routing\Matcher::match($pathinfo)`, with the current path from the `Request` object.
When passed to `match()` the value is `%E7%AE%80` but this gets passed deeper down to `Symfony\Component\Routing\Matcher\UrlMatcher::matchCollection()` but before the path gets decoded by `rawurldecode()`:
if ($ret = $this->matchCollection(rawurldecode($pathinfo) ?: '/', $this->routes)) { return $ret; }
Inside `Symfony\Component\Routing\Matcher\UrlMatcher::matchCollection()` finally the matching happens by comparing `$trimmedPathinfo` with `$staticPrefix` or in other words the encoded path `%E7%AE%80` with the decoded path 简.
Patch¶
My patch resolves the problem by decoding the base path from site configuration before it gets stored into `\TYPO3\CMS\Core\Routing\Route`.
Files