php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #77239 pathinfo strips umlauts only at the beginning
Submitted: 2018-12-04 19:32 UTC Modified: 2021-03-25 16:09 UTC
Votes:7
Avg. Score:3.7 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:4 (66.7%)
Same OS:4 (66.7%)
From: stephan dot eicher at check24 dot de Assigned:
Status: Verified Package: *Directory/Filesystem functions
PHP Version: 7.1.24 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: stephan dot eicher at check24 dot de
New email:
PHP Version: OS:

 

 [2018-12-04 19:32 UTC] stephan dot eicher at check24 dot de
Description:
------------
Pathinfo will strip umlauts from the filename beginning if locale is not correct set.

The strange thing is that it will not strip other umlauts for example if they are in the middle of the string.

I would expect that it strips all umlauts or none but not that it will strip them from the beginning but not in the string.

Test script:
---------------
<?php

setlocale(LC_ALL, 'C');

echo pathinfo('änderungs', PATHINFO_FILENAME) . PHP_EOL;

echo pathinfo('bestandübertragung', PATHINFO_FILENAME) . PHP_EOL;

Expected result:
----------------
änderungs
bestandübertragung


Actual result:
--------------
nderungs
bestandübertragung

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-05 13:53 UTC] alex dot a dot pott at gmail dot com
This problem seems to be OS dependent. If I run the following script I get different results. Locally I'm running on MacOS Mojave use homebrew for PHP 7.2.

Test script:
---------------
<?php
setlocale(LC_ALL, 'C');
var_dump(pathinfo('Ö Ü Å Ø äöüåøhello.txt'));


Output using docker:
---------------
docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.2-cli php test-locale-pathinfo.php
array(4) {
  ["dirname"]=>
  string(1) "."
  ["basename"]=>
  string(29) " Ü Å Ø äöüåøhello.txt"
  ["extension"]=>
  string(3) "txt"
  ["filename"]=>
  string(25) " Ü Å Ø äöüåøhello"
}

Output locally:
---------------
php test-locale-pathinfo.php                                                                
array(4) {
  ["dirname"]=>
  string(1) "."
  ["basename"]=>
  string(31) "Ö Ü Å Ø äöüåøhello.txt"
  ["extension"]=>
  string(3) "txt"
  ["filename"]=>
  string(27) "Ö Ü Å Ø äöüåøhello"
}
 [2021-03-25 16:09 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2021-03-25 16:09 UTC] cmb@php.net
I assume that you get exactly the same output with basename(), for
which the documentation already states:

| If path contains characters which are invalid for the current
| locale, the behavior of basename() is undefined.

So, not a bug, but needs to be documented for pathinfo() as well.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC