Skip to content

[5.x, 4.x]: bootstrap/router.php can not handle umlauts #14977

@thomas-jaeger

Description

@thomas-jaeger

What happened?

Description

If serving files in local directory, router.php does not serve files with umlauts.

Steps to reproduce

  1. Create an asset with umlauts, for example hellö.png
  2. router.php tries to serve a file named hell%C3%96.png

Expected behavior

File should be served from file system

Actual behavior

File is not found in the file system

Fix (use urldecode):

4,6c4,6
< $parts = parse_url($_SERVER['REQUEST_URI'] ?? '');
< if (!empty($parts['path'])) {
<     if (realpath($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $parts['path'])) {
---
> $path = parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH);
> if (!empty($path)) {
>     if (realpath($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . urldecode($path))) {

Craft CMS version

4.x, 5.x

PHP version

8.3

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions