php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78817 pathinfo() on filenames starting with utf-8 character fails
Submitted: 2019-11-15 10:41 UTC Modified: 2019-11-15 10:51 UTC
From: jasverix at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 7.2.24 OS: Debian Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 - 4 = ?
Subscribe to this entry?

 
 [2019-11-15 10:41 UTC] jasverix at gmail dot com
Description:
------------
We have a filename starting with a non-ASCII filename character like "Æ", "Ø" or "Å". Then we try to get the filename without extension using PATHINFO_FILENAME.

PHP will trim the first character from the resulting string.

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

$fileName = 'ÅfileÅnameÅ.docx';

// outputs "fileÅnameÅ" - missing starting character
echo pathinfo($fileName, PATHINFO_FILENAME) . "\n";

Expected result:
----------------
ÅfileÅnameÅ

Actual result:
--------------
fileÅnameÅ

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-11-15 10:42 UTC] jasverix at gmail dot com
PHP Version:
PHP 7.2.24-1+0~20191026.31+debian10~1.gbpbbacde (cli) (built: Oct 26 2019 14:20:35) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.24-1+0~20191026.31+debian10~1.gbpbbacde, Copyright (c) 1999-2018, by Zend Technologies
 [2019-11-15 10:51 UTC] sjon@php.net
-Status: Open +Status: Not a bug
 [2019-11-15 10:51 UTC] sjon@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is documented - see https://www.php.net/pathinfo

> Caution
> 
> pathinfo() is locale aware, so for it to parse a path containing multibyte characters correctly, the matching locale must be set using the setlocale() function.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 19:01:33 2024 UTC