WordPress.org

Make WordPress Core

Opened 20 months ago

Closed 20 months ago

Last modified 20 months 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:

Description


Attachments (2)

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

Download all attachments as: .zip

Change History (6)

bilalcoder20 months ago

bilalcoder20 months ago

comment:1 bilalcoder20 months ago

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

comment:2 SergeyBiryukov20 months ago

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

Could you describe the enhancements?

comment:3 bilalcoder20 months 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):

if($this->DEBUG) 
    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.

Version 5, edited 20 months ago by bilalcoder (previous) (next) (diff)

comment:4 bilalcoder20 months ago

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