php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64995 Function basename works icorrect with spaces
Submitted: 2013-06-08 12:54 UTC Modified: 2013-10-15 11:54 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: svmk-tmsk at yandex dot ru Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.4Git-2013-06-08 (Git) OS: Linux svmk-laptop 3.8.0-23-gener
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-06-08 12:54 UTC] svmk-tmsk at yandex dot ru
Description:
------------
PHP version - PHP 5.4.9-4ubuntu2 (cli) (built: Mar 11 2013 16:05:09) 

Function basename works incorrect with spaces in cyrillic encoding. This function separates filename by a space. For example basename("www/abc defg") = "defg". It should be "abc defg". The letters should be in Cyrillic like 'абв где'.

1. Set locale ru_RU.UTF-8
2. Run this code echo basename('абв где');
3. basename return 'где'. basename must return 'абв где'.

Test script:
---------------
echo basename('абв где');

Expected result:
----------------
baseline function should't divide string by space.

Actual result:
--------------
basename('путь до каталога/абв  где') = 'где'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-08 15:49 UTC] rasmus@php.net
-Status: Open +Status: Feedback
 [2013-06-08 15:49 UTC] rasmus@php.net
Are you sure you are using UTF-8 and not CP1251 there? You set your locale to 
UTF8, and I tested your code with the UTF8:

echo basename('абв где');

And it works just fine.

eg.

php > echo basename('путь до каталога/абв  где');
абв  где

If you are using CP1251 you can try calling:

mb_internal_encoding("CP1251");

before your basename() call. Does it change anything?
 [2013-10-15 11:54 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Oct 21 16:01:26 2019 UTC