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)    
Subscription  


 [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) )

Comments

 [2006-02-09 22:58 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!