php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26574 basename() cannot work with Chinese Path name
Submitted: 2003-12-09 22:51 UTC Modified: 2004-01-22 04:38 UTC
From: gaoyong at crtvu dot edu dot cn Assigned: moriyoshi (profile)
Status: Closed Package: *Directory/Filesystem functions
PHP Version: 4.3.4 OS: Windows 2k SP4
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gaoyong at crtvu dot edu dot cn
New email:
PHP Version: OS:

 

 [2003-12-09 22:51 UTC] gaoyong at crtvu dot edu dot cn
Description:
------------
if the parameter of basename() contain Chinese path name like this "e:\????\2.jpg",the function can not work.
The HTML contain the path "e:\????\2.jpg"
First, I copy the upload temp file from "c:\winnt\temp" to the cache path("d:\oems\....\cach"),
Secondly, I parse the HTML content that user submiting,and getting the image "SRC" like "e:\????\2.jpg",
third, using basename() to get the filename(2.jpg)
but the function return "e:\????\2.jpg"
When The path name doesn't contain Chinese Character and space,it can work well.


Reproduce code:
---------------
	function Picstr_handle($s)
	{
......
		$s=stripslashes($s);
		$tmpImg = explode("SRC=\"",$s);
		$tmpImg1 = explode("\"></IMG>",$s);
......
		for ($i =1; $i< count($tmpImg); $i++)
		{
			$sourcefilepath[$i] = explode("\"></IMG>",$tmpImg[$i]);

			$destfilepath[$i] = $ServerRootPath."/exam/image/".$QuestionPathName[$QuestionType];
			if (!is_dir($destfilepath[$i]))
			{mkdir($destfilepath[$i],0);}
			$destfilepath[$i] .= "/".$InputUser;
			if (!is_dir($destfilepath[$i]))
			{mkdir($destfilepath[$i],0);}
			$destfilepath[$i] .= "/".date("Ymd",time());
			if (!is_dir($destfilepath[$i]))
			{mkdir($destfilepath[$i],0);}			
			$destfilepath[$i] .= "/" .substr(md5(basename($sourcefilepath[$i][0])),2,8) .substr(basename($sourcefilepath[$i][0]),strlen(basename($sourcefilepath[$i][0]))-4,4);
			$sourcefilepath[$i][0] =$ServerRootPath."/exam/image/cache/".basename($sourcefilepath[$i][0]);
			if(!is_file($destfilepath[$i]))
			{
				if (!copy($sourcefilepath[$i][0],$destfilepath[$i]))
				{ echo "???Ƶ???" .$sourcefilepath[$i][0]." ʧ??...<br>" ;break;exit(); }
				if (is_file($sourcefilepath[$i][0]))
				{unlink($sourcefilepath[$i][0]);}
			}
		}

Expected result:
----------------
Warning: copy(D:/oems/teachingcenter_test/webroot/exam/image/cache/E:\????\2.JPG): failed to open stream: Invalid argument in D:\oems\teachingcenter_test\webroot\exam\datainput\insert.html on line 77
???Ƶ???D:/oems/teachingcenter_test/webroot/exam/image/cache/E:\????\2.JPG ʧ??...


Actual result:
--------------
no warning

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-10 00:55 UTC] moriyoshi@php.net
This problem appears to be caused by the wrong usage of 
IsDBCSLeadByte().

 [2004-01-22 04:38 UTC] moriyoshi@php.net
Already fixed in php5-cvs, but not sure whether to merge 
it to the php4 branch.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 02:01:28 2024 UTC