Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.1

Bug #8102 Loading file extension and checking extension gives binary for ascii files
Submitted: 2006-07-02 18:09 UTC
From: roychri at php dot net Assigned: jorrit
Status: Closed Package: Net_FTP (version 1.3.2)
PHP Version: 4.3.11 OS: Mandrake Linux release 8.2 (Blue
Roadmaps: 1.3.3    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 31 - 24 = ?

 
 [2006-07-02 18:09 UTC] roychri at php dot net (Christian Roy)
Description: ------------ I use getExtensionsFile() to load the ini file and then I use checkFileExtension() to determine the transfer mode based on the file extension. The function getExtensionsFile() is assigning the ini file parsed into a variable called _file_extension but everywhere in the FTP.php uses _file_extensions. I think that's a simple typo mistake in FTP.php. The function checkFileExtension() is using empty() to find out if that extension exists in the _file_extensions array but since the value is set to 0 for ascii, it thinks it's not in the in file and therefor return the default mode (binary). The function checkFileExtension() regular expression assumes there's only one dot in the filename and therefor cannot extract the correct extension from the filename when it contains multiple dots. To make it work, here are the changes I've made (patch format): --- /usr/local/lib/php/Net/FTP.php~ Sat Jul 1 10:03:22 2006 +++ /usr/local/lib/php/Net/FTP.php Sun Jul 2 10:52:28 2006 @@ -1427,7 +1427,7 @@ function checkFileExtension($filename) { - $pattern = "/\.(.*)$/"; + $pattern = "/\.([^\.]+)$/"; $has_extension = preg_match($pattern, $filename, $eregs); if (!$has_extension) { return $this->_mode; @@ -1435,7 +1435,7 @@ $ext = $eregs[1]; } - if (!empty($this->_file_extensions[$ext])) { + if (isset($this->_file_extensions[$ext])) { return $this->_file_extensions[$ext]; } @@ -1642,7 +1642,7 @@ return $this->raiseError("Extensions-file '$filename' is not readable", NET_FTP_ERR_EXTFILEREAD_FAILED); } - $this->_file_extension = @parse_ini_file($filename); + $this->_file_extensions = @parse_ini_file($filename); return true; } I hope this helps. Let me know if you need any more info. Thanks. -- christian roy Test script: --------------- $ftp =& new Net_FTP(); $loaded = $ftp->getExtensionsFile($path_to_ext_file."extensions.ini"); $type = $ftp->checkFileExtension("index.html"); print "index.html: type = $type\n"; $type = $ftp->checkFileExtension("www.google.com.html"); print "www.google.com.html: type = $type\n"; Expected result: ---------------- index.html: type = 0 www.google.com.html: type = 0 Actual result: -------------- index.html: type = 1 www.google.com.html: type = 1

Comments

 [2007-11-24 19:50 UTC] jorrit (Jorrit Schippers)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.