#21559 closed enhancement (maybelater)
class-pop3 enhancements
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | External Libraries | Keywords: | has-patch |
| Focuses: | Cc: |
Description
Attachments (2)
Change History (6)
#2
@
13 years ago
- Component changed from Mail to External Libraries
- Milestone Awaiting Review deleted
#3
@
13 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):
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.
#4
@
13 years ago
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 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 found a simple 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.
Could you describe the enhancements?