[wp-trac] [WordPress Trac] #21559: class-pop3 enhancements

WordPress Trac wp-trac at lists.automattic.com
Mon Aug 13 13:10:25 UTC 2012


#21559: class-pop3 enhancements
--------------------------------+-------------------------
 Reporter:  bilalcoder          |       Owner:
     Type:  enhancement         |      Status:  closed
 Priority:  normal              |   Milestone:
Component:  External Libraries  |     Version:
 Severity:  normal              |  Resolution:  maybelater
 Keywords:  has-patch           |
--------------------------------+-------------------------

Comment (by bilalcoder):

 I intended to make the code more readable and will structured, added some
 methods like '''send()''' and '''get_reply()''', they contain both a DEBUG
 condition to log the string that is being handled to avoid checking each
 time throughout the code (example):

 {{{
 if($this->DEBUG)
     error_log("POP3 SEND [connect: $server] GOT [$reply]",0);
 }}}

 Notice that the get_reply() strips CRLF from the response string
 automatically [http://core.trac.wordpress.org/browser/trunk/wp-includes
 /class-pop3.php#L463/ instead of doing it each time outside the function
 ], moreover , i found a bug in pop_list()
 [http://core.trac.wordpress.org/browser/trunk/wp-includes/class-
 pop3.php#L303/ class-pop3#L303] where some email providers return an extra
 word (messages) in the response, the workaround
 ([http://core.trac.wordpress.org/attachment/ticket/21559/class-
 pop3.php#L314/ #L314]) i suggested is to preg_match for number sequences
 and get last number matched in the list.

 I found a simple [http://core.trac.wordpress.org/attachment/ticket/21559
 /class-pop3.php#L535/ workaround] for parse_banner(), it is possible to
 use preg_match to get strings that are located between <> , seems better
 to me than:


 {{{
     function parse_banner ( $server_text ) {
         $outside = true;
         $banner = "";
         $length = strlen($server_text);
         for($count =0; $count < $length; $count++)
         {
             $digit = substr($server_text,$count,1);
             if(!empty($digit))             {
                 if( (!$outside) && ($digit != '<') && ($digit != '>') )
                 {
                     $banner .= $digit;
                 }
                 if ($digit == '<')
                 {
                     $outside = false;
                 }
                 if($digit == '>')
                 {
                     $outside = true;
                 }
             }
         }
         $banner = $this->strip_clf($banner);    // Just in case
         return "<$banner>";
     }
 }}}

 i added two optional arguments to the constructor $timeout ( setting
 timeout ) and $connect ( if true, then connect to the pop3 server ).

 i apologize if there is any mistakes in the text.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21559#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list