Bug #62119 [Com]: basename broken with non-ASCII-chars
| From: | christiansen dot jacob at gmail dot com | Date: | Wed, 10 Jun 2015 08:56:22 +0000 |
| Subject: | Bug #62119 [Com]: basename broken with non-ASCII-chars | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193277@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62119&edit=1
ID: 62119
Comment by: christiansen dot jacob at gmail dot com
Reported by: thomas dot hebinck at digionline dot de
Summary: basename broken with non-ASCII-chars
Status: Verified
Type: Bug
Package: *Directory/Filesystem functions
Operating System: Linux/Ubuntu
PHP Version: 5.3.13
Block user comment: N
Private report: N
New Comment:
This is still an issue in PHP 5.6 and it is PHP's problem, since PHP roll its own
implementation of basename.
The problem seems to occur when running basename on a string that have a multibyte char as the first
char when LC_TYPE is set to POSIX. Which seems to be default for PHP.
On way to solve this is to set the LC_TYPE to UTF-8, but I guess that PHP should handle this.
Previous Comments:
------------------------------------------------------------------------
[2014-08-04 17:04:32] bugs dot php dot net at dw-perspective dot org dot uk
In https://bugzilla.redhat.com/show_bug.cgi?id=1126399,
a glibc developer says that glibc's basename() is not locale-dependent - and therefore that if
PHP's basename() is locale dependent, then that points to a PHP issue.
------------------------------------------------------------------------
[2014-08-04 10:36:04] bugs dot php dot net at dw-perspective dot org dot uk
I have this problem too, on a Fedora 20 (=current) system.
Interestingly, the system's "basename" binary, which I'd assume is making the
same glibc call, does not have this problem:
# LANG=C basename '/test/äaä.txt'
äaä.txt
So perhaps the problem is more subtle that a simple glibc bug?
------------------------------------------------------------------------
[2012-07-03 15:29:18] pollita@php.net
Verified on Debian, but since this is the behavior of the underlying libc
implementation, I'm not sure it's PHP's role to fix it.
Leaving open for now since we could potentially detect this case and deal with it,
but on initial look I'm inclined to push it off on the OS.
------------------------------------------------------------------------
[2012-05-23 08:38:45] thomas dot hebinck at digionline dot de
Description:
------------
With the default locale setting "C", basename() drops non-ASCII-chars at the beginning of
a filename.
Test script:
---------------
$path='/test/äaä.txt';
echo $path."\n";
setlocale(LC_ALL,'C');
echo dirname($path).'/'.basename($path)."\n";
setlocale(LC_ALL,'en_US.iso885915'); // bash: locale -a
echo dirname($path).'/'.basename($path)."\n";
Expected result:
----------------
/test/äaä.txt
/test/äaä.txt
/test/äaä.txt
Actual result:
--------------
/test/äaä.txt
/test/aä.txt
/test/äaä.txt
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62119&edit=1