|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61309 DBCS included UNC path broken due to incorrect toupper usage
Submitted: 2012-03-07 02:50 UTC Modified: 2012-03-07 09:02 UTC
From: ku at digitaldolphins dot jp Assigned:
Status: Duplicate Package: Directory function related
PHP Version: trunk-SVN-2012-03-07 (snap) OS: Windows Server 2008 R2 Foundatio
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ku at digitaldolphins dot jp
New email:
PHP Version: OS:


 [2012-03-07 02:50 UTC] ku at digitaldolphins dot jp
scandir() fails on all of following conditions:
- use UNC path with DBCS character(s).
- second byte in one DBCS character includes lower letter ('a' to 'z').

for example: \\DD5\フォルダ

("フォルダ" means "folder")

each character -> to byte array as CP932 (aka Shift_JIS) -> to ascii:

フ -> 83 74 -> .t
ォ -> 83 48 -> .H
ル -> 83 8B -> ..
ダ -> 83 5F -> ._

incorrect toupper usage brings "サォルダ" from "フォルダ".

Expected result shows: By using pathced php5, it is looking for right place 
"\\DD5\フォルダ" (ok).

[CASE1] in Actual result shows: By using php5 snap, it is looking for wrong 
place "\\DD5\サォルダ" (wrong). network path is not found!

[CASE2] in Actual result shows: By using php5 snap. I prepared a UNC folder with 
wrong name "サォルダ".

About my fix method:
- toupper/tolower is ok, however path consists from "characters", not "bytes". 
- try _mbsinc or such to advance pointer in "character" unit. 

Test script:

echo print_r(scandir("\\\\DD5\\フォルダ"));


Expected result:
C:\php-sdk\php54dev\vc9\x86\php5.4-201203070030>Release_TS\php.exe \php5\test.php
    [0] => .
    [1] => ..
    [2] => Ok. it is 'fo-ru-da'.txt

Actual result:
C:\php5>php.exe test.php
PHP Warning:  scandir(\\DD5\フォルダ,\\DD5\フォルダ): ネットワーク名が見つかりません。 
(code: 67) in C:\php5\test.php on line 3
PHP Warning:  scandir(\\DD5\フォルダ): failed to open dir: Permission denied in 
C:\php5\test.php on line 3
PHP Warning:  scandir(): (errno 13): Permission denied in C:\php5\test.php on 
line 3

C:\php5>php.exe test.php
    [0] => .
    [1] => ..
    [2] => Wrong. it is 'sa-lo-ru-da'.txt


php54_dbcs_win_unc_1 (last revision 2012-03-07 02:50 UTC by ku at digitaldolphins dot jp)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-07 09:02 UTC]
We already have reports about that.

Full unicode/wildchar support is being worked on.
 [2012-03-07 09:02 UTC]
-Status: Open +Status: Duplicate
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 12:01:32 2024 UTC