Bug #53350 [NEW]: Cannot use paths that contain certain SJIS chars

From: Date: Fri, 19 Nov 2010 03:44:51 +0000
Subject: Bug #53350 [NEW]: Cannot use paths that contain certain SJIS chars
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-156209@lists.php.net to get a copy of this message
From: Operating system: Windows XP SP3 Japanese PHP version: 5.3.3 Package: Filesystem function related Bug Type: Bug Bug description:Cannot use paths that contain certain SJIS chars Description: ------------ Paths in Japanese WinXP are all handled in Shift-JIS encoding ('SJIS-win' for mb_convert_encoding(), etc.). Shift-JIS contains a number of commonly-used characters for which the second byte is 0x5C (e.g. 表, 0x955C). 0x5C happens to be the encoding for backslash \, the escape character. When one of these characters is contained within a path, a large number of filesystem-related functions will fail to interpret the path correctly, and will simply not work, or will do weird things such as create or read unrequested files (see the provided test script for details). Test script: --------------- <?php // Assume file '表.txt' exists in the cwd mb_internal_encoding('SJIS'); echo filesize('表.txt')); // This works ok echo file_get_contents('表.txt'); // This fails: 'failed to open stream: No such file or directory' // Furthermore, if "表表.txt" exists then its contents will be shown by the previous command (!?!?) file_put_contents('表.txt', 'blahblahblah'); // A new file '表表.txt' is created (!?!?) ?> Expected result: ---------------- file_get_contents() should read the correct file and not fail. file_put_contents() should not create unrequested files. Actual result: -------------- file_get_contents(), is_file(), etc. fail to correctly interpret any path containing 表 and other SJIS chars with a second byte of 0x5C. -- Edit bug report at http://bugs.php.net/bug.php?id=53350&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53350&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53350&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53350&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53350&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53350&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53350&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53350&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53350&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53350&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53350&r=support Expected behavior: http://bugs.php.net/fix.php?id=53350&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53350&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53350&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53350&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53350&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53350&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53350&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53350&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53350&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53350&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53350&r=mysqlcfg

« previous php.bugs (#156209) next »