Make WordPress Core

Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#3838 closed defect (bug) (duplicate)

class-pop3's get() method doesn't handle newlines correctly when reading a mail

Reported by: nreid's profile nreid Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.1
Component: General Keywords:
Focuses: Cc:

Description

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

Attachments (1)

class-pop3.php (21.5 KB) - added by nreid 17 years ago.

Download all attachments as: .zip

Change History (5)

@nreid
17 years ago

#1 @nreid
17 years ago

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

#2 @JeremyVisser
17 years ago

Duplicate of what ticket number?

#3 @Nazgul
17 years ago

Duplicate of #3836

#4 @foolswisdom
17 years ago

  • Milestone 2.3 deleted
Note: See TracTickets for help on using tickets.