Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#21559 closed enhancement (maybelater)

class-pop3 enhancements

Reported by: 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 3 years ago.
patch.diff (29.0 KB) - added by bilalcoder 3 years ago.

Download all attachments as: .zip

Change History (6)

@bilalcoder3 years ago

@bilalcoder3 years ago

comment:1 @bilalcoder3 years ago

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

comment:2 @SergeyBiryukov3 years ago

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

Could you describe the enhancements?

comment:3 @bilalcoder3 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 3 years ago by bilalcoder (previous) (diff)

comment:4 @bilalcoder3 years ago

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