php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50203 Apache +mod_php can't load script with non-ASCII name
Submitted: 2009-11-17 10:30 UTC Modified: 2011-03-17 14:26 UTC
Votes:10
Avg. Score:4.8 ± 0.4
Reproduced:9 of 9 (100.0%)
Same Version:7 (77.8%)
Same OS:6 (66.7%)
From: vadim at sukhomlinov dot ru Assigned:
Status: Duplicate Package: Apache2 related
PHP Version: 5.3.0 OS: win32 only - Windows XP SP3
Private report: No CVE-ID: None
 [2009-11-17 10:30 UTC] vadim at sukhomlinov dot ru
Description:
------------
When I use Apache 2.2.14 + PHP 5.3 standalone and request such script directly by name it doesn't start (at least with mod_php), but in log files I see something like:
[error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required 'E:/www/test2/\xd0\x9d\xd0\xbe\xd0\xb2\xd0\xbe\xd1\x81\xd1\x82\xd0\xb8.php' (include_path='.;C:\\php5\\pear') in Unknown on line 0, referer: http://test2.ru/

I discovered this is because PHP doesn't translate UTF-8 filename passed from Apache to coding (Unicode-16?) used by Windows, and thus can't open it. It works perfectly on Linux as Apache, PHP & Linux filesystem use same UTF-8...

Having this feature is useful for creating SEO-optimized sites with URLs containing keywords. I don't ask to fix Unicode in general, but at least for Windows, where it's known Apache will receive link as UTF-8 and pass it as is to PHP, we can translate it into correct encoding before calling system functions. I guess this is couple lines of code for Windows build.

Reproduce code:
---------------
1. take any .php script and rename it to any name with UTF-8 2 byte+ symbols. I used russian ???????.php.
2. Configure Apache on Windows to use PHP as module (loadmodule)
3. Try to request this script from browser



Expected result:
----------------
Script won't load with 500 code. However, it runs when it's name has only ASCII characters.

Actual result:
--------------
[error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required 'E:/www/test2/\xd0\x9d\xd0\xbe\xd0\xb2\xd0\xbe\xd1\x81\xd1\x82\xd0\xb8.php' (include_path='.;C:\\php5\\pear') in Unknown on line 0, referer: http://test2.ru/

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-17 21:58 UTC] tsanchev at gmail dot com
Directory listing from pache:



Index of /cosmetic-academy

Parent Directory
assets/
pl0_p0_Козметик Академи_html.php
ддадада д асд асдdasdasd aдасффс.txt



when try to execute the sctript in the directory i get this error:


Warning: Unknown: failed to open stream: No such file or directory in Unknown on 
line 0

Fatal error: Unknown: Failed opening required 'D:/web/www/cosmetic-
academy/pl0_p0_Козметик Академи_html.php' (include_path='.;C:\php5\pear') in 
Unknown on line 0


if the name contain only ascii chars it works perfectly
 [2011-03-17 14:08 UTC] lost dot guadelenn at gmail dot com
The bug is still present in php 5.3.5 and apache 2.2.17.
(Both are latest stable versions).
OS is Win7 64 bit (php and apache are 32-bit).
 [2011-03-17 14:13 UTC] pajoye@php.net
-Status: Open +Status: Duplicate
 [2011-03-17 14:13 UTC] pajoye@php.net
There is already a feature request for Unicode Filesystem support. And no, it is 
not implemeneted yet.
 [2011-03-17 14:17 UTC] lost dot guadelenn at gmail dot com
A note to developers:
Apache has api for path manipulation: http://apr.apache.org/docs/apr/0.9/group__apr__filepath.html
Note function apr_filepath_encoding() which retrieves current path encoding.
Also note win32 function GetShortPathName() which converts any valid long pathname to 8.3 ascii format.
 [2011-03-17 14:22 UTC] lost dot guadelenn at gmail dot com
Hi pajoye.

Maybe this bug can be fixed without such complex things as Unicode Filesystem?
(See my comment above - there is api already in both apache and win32)
 [2011-03-17 14:26 UTC] pajoye@php.net
That's only part of the problem, the top of the iceberg.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC