php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47954 pathinfo() returns invalid filename for utf-8 file
Submitted: 2009-04-12 00:36 UTC Modified: 2009-04-21 01:00 UTC
Votes:6
Avg. Score:4.3 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:1 (16.7%)
Same OS:3 (50.0%)
From: top dot bagger at bk dot ru Assigned:
Status: No Feedback Package: *Unicode Issues
PHP Version: 5.2.9 OS: Linux 2.6.18
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: top dot bagger at bk dot ru
New email:
PHP Version: OS:

 

 [2009-04-12 00:36 UTC] top dot bagger at bk dot ru
Description:
------------
pathinfo() function returns invalid "filename" array part for utf-8 filename



Reproduce code:
---------------
<?php

$utf8str = "&#1055;&#1056;&#1048;&#1042;&#1045;&#1058;_&#1052;&#1045;&#1044;&#1042;&#1045;&#1044;.mp4";
$path = pathinfo($utf8str);

var_dump($path['filename']);

?>


Expected result:
----------------
string(25) "&#1055;&#1056;&#1048;&#1042;&#1045;&#1058;_&#1052;&#1045;&#1044;&#1042;&#1045;&#1044;" 

Actual result:
--------------
string(13) "_&#1052;&#1045;&#1044;&#1042;&#1045;&#1044;" 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-12 00:46 UTC] top dot bagger at bk dot ru
utf-8 strings i submitid there got replaced by entities :( The main thing is there should be a "_" sign in filename. Then "filename" part becomes splitted by it. If there is no "_" sign, the "filename" part is empty.
 [2009-04-13 12:04 UTC] jani@php.net
Please provide a proper test case. I tested this on command line and 
it works just fine. (check your charset settings..)
 [2009-04-21 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-08-07 12:25 UTC] brunner dot adam at gmail dot com
Can confirm on Linux with PHP 5.2.9

var_dump(pathinfo("foobar.ext", PATHINFO_FILENAME)); // string(6) "foobar"
var_dump(pathinfo("f&#337;oobar.ext", PATHINFO_FILENAME)); //string(8) "főoobar"
var_dump(pathinfo("&#337;oobar.ext", PATHINFO_FILENAME)); //string(5) "oobar"

This works well in CLI mode!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 01:01:30 2024 UTC