Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#21559 closed enhancement (maybelater)

class-pop3 enhancements

Reported by: bilalcoder's profile bilalcoder Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: External Libraries Keywords: has-patch
Focuses: Cc:


Attachments (2)

class-pop3.php (17.1 KB) - added by bilalcoder 12 years ago.
patch.diff (29.0 KB) - added by bilalcoder 12 years ago.

Download all attachments as: .zip

Change History (6)

12 years ago

#1 @bilalcoder
12 years ago

  • Resolution set to maybelater
  • Status changed from new to closed

#2 @SergeyBiryukov
12 years ago

  • Component changed from Mail to External Libraries
  • Milestone Awaiting Review deleted

Could you describe the enhancements?

#3 @bilalcoder
12 years ago

I intended to make the code more readable and well 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):

    error_log("POP3 SEND [connect: $server] GOT [$reply]",0);

Notice that the get_reply() strips CRLF from the response string automatically instead of doing it each time outside the function , moreover , i found a bug in pop_list() class-pop3#L303 where some email providers return an extra word (messages) in the response, the workaround (#L314) i suggested is to preg_match for number sequences and get last number matched in the list.

I made simple modification to parse_banner(), matching strings that are located between <> using preg_match seemed better to me:

    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 are any mistakes in the text, waiting for notes and corrections.

Last edited 12 years ago by bilalcoder (previous) (diff)

#4 @bilalcoder
12 years ago

Last edited 12 years ago by bilalcoder (previous) (diff)
Note: See TracTickets for help on using tickets.