Skip to content

Commit

Permalink
Fix issue with clients that send broken, mixed EOL, messages.
Browse files Browse the repository at this point in the history
Nine, for example, currently does this and it completly breaks
the email parsing code. Also, use Horde_Stream::search().
  • Loading branch information
mrubinsk committed Dec 10, 2014
1 parent e1952b0 commit db05dd1
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions framework/ActiveSync/lib/Horde/ActiveSync/Rfc822.php
Expand Up @@ -224,21 +224,14 @@ public function getBytes()
*/
protected function _findHeader()
{
$i = 0;
while (!$this->_stream->eof()) {
$data = $this->_stream->substring(0, 8192);
$hdr_pos = strpos($data, "\r\n\r\n");
if ($hdr_pos !== false) {
return array($hdr_pos + ($i * 8192), 4);
}
$hdr_pos = strpos($data, "\n\n");
if ($hdr_pos !== false) {
return array($hdr_pos + ($i * 8192), 2);
}
$i++;
// Look for the EOL that is found first in the message. Some clients
// are sending mixed EOL in S/MIME signed messages.
switch ($this->_stream->getEOL()) {
case "\n":
return array($this->_stream->search("\n\n"), 2);
case "\r\n":
return array($this->stream->search("\r\n\r\n"), 4);
}
$this->_stream->end();
return array($this->_stream->pos(), 0);
}

}

0 comments on commit db05dd1

Please sign in to comment.