Bug #61309 [NEW]: DBCS included UNC path broken due to incorrect toupper usage

From: Date: Wed, 07 Mar 2012 02:50:09 +0000
Subject: Bug #61309 [NEW]: DBCS included UNC path broken due to incorrect toupper usage
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-168217@lists.php.net to get a copy of this message
From: Operating system: Windows Server 2008 R2 Foundatio PHP version: trunk-SVN-2012-03-07 (snap) Package: Directory function related Bug Type: Bug Bug description:DBCS included UNC path broken due to incorrect toupper usage 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 bug report at https://bugs.php.net/bug.php?id=61309&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=61309&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=61309&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=61309&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=61309&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=61309&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=61309&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=61309&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=61309&r=needscript Try newer version: https://bugs.php.net/fix.php?id=61309&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=61309&r=support Expected behavior: https://bugs.php.net/fix.php?id=61309&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=61309&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=61309&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=61309&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=61309&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=61309&r=dst IIS Stability: https://bugs.php.net/fix.php?id=61309&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=61309&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=61309&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=61309&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=61309&r=mysqlcfg

« previous php.bugs (#168217) next »