[wp-trac] [WordPress Trac] #3838: class-pop3's get() method doesn't
handle newlines correctly when reading a mail
WordPress Trac
wp-trac at lists.automattic.com
Wed Feb 21 23:12:20 GMT 2007
#3838: class-pop3's get() method doesn't handle newlines correctly when reading a
mail
---------------------+------------------------------------------------------
Reporter: nreid | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: 2.3
Component: General | Version: 2.1
Severity: normal | Keywords:
---------------------+------------------------------------------------------
I'm using wordpress 2.1
When posting to a blog using the e-mail feature, I was noticing that long
subjects were being truncated. I searched into wp-mail.php and it
appeared that the subject line that is processed was being 'truncated' in
the class-pop3.php. In the get method, around line 396 in class-pop3.php,
the fgets method simply reads from the 'fp' until newlines are reached,
and puts those lines into the returned MsgArray. However, when debugging
the lines read by fgets, I was seeing that my long subject lines were
being split into multiple lines, and since the line processor in wp-mail
only looks at one line at a time, it was missing the 'extra' lines. My
solution was to only add another line to the MsgArray if the beginning of
that line is a non-whitespace character. According to the spec, it
appears that lines in the header of the message will always either start
with a known header, such as 'Reply-to:', or 'Subject:', etc, or be
prepended with a space. If there's a space, it means that the line
belongs to the prior line's data. My rewritten while look looks like
this:
$line = "";
while ( !ereg("^\.\r\n",$line))
{
$line = fgets($fp,$buffer);
if (preg_match("/^\s+/",$line)) {
$MsgArray[$count-1] .= $line;
continue;
}
if(empty($line)) { break; }
$MsgArray[$count] = $line;
$count++;
}
return $MsgArray;
Basically, the preg_match checks if the 'just-read' line begins with a
space. If so, it appends it to the last read line (the
MsgArray[$count-1]) and continue's. This appears to work with e-mails
from my testing.
sending e-mails with long subjects > 60 or so characters, the
--
Ticket URL: <http://trac.wordpress.org/ticket/3838>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list