Skip to content

Commit

Permalink
Fix preparing the message body data in certain cases.
Browse files Browse the repository at this point in the history
When client sends OPTIONS for both plain and html, and email
only contains html we were incorrectly transforming the HTML into
plaintext. This could also have been causing some strange behavior
with regards to truncation like e.g., truncating the data when
no truncation was needed or indicating it's truncated on the client
when it's not etc...
  • Loading branch information
mrubinsk committed Dec 24, 2014
1 parent 8e4b4f1 commit eb816de
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions framework/ActiveSync/lib/Horde/ActiveSync/Imap/MessageBodyData.php
Expand Up @@ -416,31 +416,27 @@ protected function _getHtmlPart(
0,
$this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_HTML]['truncationsize'],
$charset);
} elseif ($convert_to_plain) {
$html = Horde_Text_Filter::filter(
}
if ($convert_to_plain) {
$html_plain = Horde_Text_Filter::filter(
$html, 'Html2text', array('charset' => $charset));

// Get the new size, since it probably changed.
$html_size = Horde_String::length($html);
$html__plain_size = Horde_String::length($html_plain);
if (!empty($this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN]['truncationsize'])) {
// EAS >= 12.0 truncation
$html = Horde_String::substr(
$html,
$html_plain = Horde_String::substr(
$html_plain,
0,
$this->_options['bodyprefs'][Horde_ActiveSync::BODYPREF_TYPE_PLAIN]['truncationsize'],
$charset);
}
}

// Was the part truncated?
$truncated = $html_size > Horde_String::length($html);

if ($convert_to_plain) {
$results['plain'] = array(
'charset' => $charset,
'body' => $html,
'truncated' => $truncated,
'size' => $html_size
'body' => $html_plain,
'truncated' => $html_size > Horde_String::length($html_plain),
'size' => $html_plain_size
);
}

Expand All @@ -450,7 +446,7 @@ protected function _getHtmlPart(
'charset' => $charset,
'body' => $html,
'estimated_size' => $html_size,
'truncated' => $truncated);
'truncated' => $html_size > Horde_String::length($html));
}

return $results;
Expand Down

0 comments on commit eb816de

Please sign in to comment.