Edit report at https://bugs.php.net/bug.php?id=61309&edit=1

 ID:                 61309
 Updated by:         paj...@php.net
 Reported by:        ku at digitaldolphins dot jp
 Summary:            DBCS included UNC path broken due to incorrect
                     toupper usage
-Status:             Open
+Status:             Duplicate
 Type:               Bug
 Package:            Directory function related
 Operating System:   Windows Server 2008 R2 Foundatio
 PHP Version:        trunk-SVN-2012-03-07 (snap)
 Block user comment: N
 Private report:     N

 New Comment:

We already have reports about that.

Full unicode/wildchar support is being worked on.


Previous Comments:
------------------------------------------------------------------------
[2012-03-07 02:50:09] ku at digitaldolphins dot jp

Description:
------------
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:
---------------
<?php

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

?>

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

Actual result:
--------------
[CASE1]
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
1

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



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61309&edit=1

Reply via email to