From 98128f13fcdc8dca6ebefcdc93dc94b00322abb5 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 16 Nov 2012 13:49:02 -0500
Subject: [PATCH] Rename option password_supported_hosts to password_hosts, code cleanup
---
program/include/rcube_message.php | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/program/include/rcube_message.php b/program/include/rcube_message.php
index fe2fcf3..74bf457 100644
--- a/program/include/rcube_message.php
+++ b/program/include/rcube_message.php
@@ -198,27 +198,29 @@
* Determine if the message contains a HTML part
*
* @param bool $recursive Enables checking in all levels of the structure
+ * @param bool $enriched Enables checking for text/enriched parts too
*
* @return bool True if a HTML is available, False if not
*/
- function has_html_part($recursive = true)
+ function has_html_part($recursive = true, $enriched = false)
{
// check all message parts
foreach ($this->parts as $part) {
- if ($part->mimetype == 'text/html') {
+ if ($part->mimetype == 'text/html' || ($enriched && $part->mimetype == 'text/enriched')) {
// Level check, we'll skip e.g. HTML attachments
if (!$recursive) {
$level = explode('.', $part->mime_id);
- // Level too high
- if (count($level) > 2) {
+ // Skip if level too deep or part has a file name
+ if (count($level) > 2 || $part->filename) {
continue;
}
// HTML part can be on the lower level, if not...
if (count($level) > 1) {
- // It can be an alternative or related message part
- $parent = $this->mime_parts[0];
+ array_pop($level);
+ $parent = $this->mime_parts[join('.', $level)];
+ // ... parent isn't multipart/alternative or related
if ($parent->mimetype != 'multipart/alternative' && $parent->mimetype != 'multipart/related') {
continue;
}
@@ -268,10 +270,6 @@
}
else if ($part->mimetype == 'text/html') {
$out = $this->get_part_content($mime_id);
-
- // remove special chars encoding
- $trans = array_flip(get_html_translation_table(HTML_ENTITIES));
- $out = strtr($out, $trans);
// create instance of html2text class
$txt = new html2text($out);
@@ -370,6 +368,11 @@
foreach ($structure->parts as $p => $sub_part) {
$sub_mimetype = $sub_part->mimetype;
+
+ // skip empty text parts
+ if (!$sub_part->size && preg_match('#^text/(plain|html|enriched)$#', $sub_mimetype)) {
+ continue;
+ }
// check if sub part is
if ($sub_mimetype == 'text/plain')
@@ -477,7 +480,7 @@
if ($plugin['abort'])
continue;
- if ($part_mimetype == 'text/html') {
+ if ($part_mimetype == 'text/html' && $mail_part->size) {
$got_html_part = true;
}
--
Gitblit v1.9.1