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

Bug #4836 Off-by-one error in regex for Windows directory listings
Submitted: 2005-07-14 22:57 UTC
From: jeffg at interkey dot net Assigned: toby
Status: Closed Package: Net_FTP
PHP Version: 4.3.11 OS: Windows 2000 Server
Roadmaps: (Not assigned)    
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:
Solve the problem : 47 - 41 = ?

 [2005-07-14 22:57 UTC] jeffg at interkey dot net
Description: ------------ When attempting to obtain a directory listing from a Windows FTP server via ls(), the regular expression assigns the string value "<DIR>" to the is_dir attribute of the file's entry in the listing. Unfortunately, the regular expression is structured in such a way that it captures the filesize if the file is not a directory, and any file with a size greater than zero is erroneously tagged as being a directory. This obviously mucks up getRecursive() when the function attempts to descend into a directory that is actually a file. Reproduce code: --------------- The original code, at line 576, is as follows: 'windows' => array( 'pattern' => '/(.+)\s+(.+)\s+((<DIR>)|[0-9]+)\s+(.+)/', 'map' => array('name'=>5,'date'=>1,'is_dir'=>3) ) 3 is an inappropriate match, as it captures either <DIR> or the filesize. It should be match number 4, the (<DIR>) inside match number 3: 'windows' => array( 'pattern' => '/(.+)\s+(.+)\s+((<DIR>)|[0-9]+)\s+(.+)/', 'map' => array('name'=>5,'date'=>1,'is_dir'=>4) )


 [2006-02-09 22:58 UTC] toby
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the 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.