From 2965a981b7ec22866fbdf2d567d87e2d068d3617 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli <thomas@roundcube.net> Date: Fri, 31 Jul 2015 16:04:08 -0400 Subject: [PATCH] Allow to search and import missing PGP pubkeys from keyservers using Publickey.js --- program/steps/mail/func.inc | 68 ++++++++++++++++++++++----------- 1 files changed, 45 insertions(+), 23 deletions(-) diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index e33e965..a90541d 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -64,17 +64,6 @@ $mbox_name = $RCMAIL->storage->get_folder(); if (empty($RCMAIL->action)) { - // initialize searching result if search_filter is used - if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL') { - $RCMAIL->storage->search($mbox_name, $_SESSION['search_filter'], RCUBE_CHARSET, rcmail_sort_column()); - - $search_request = md5($mbox_name.$_SESSION['search_filter']); - $_SESSION['search'] = $RCMAIL->storage->get_search_set(); - $_SESSION['search_request'] = $search_request; - - $OUTPUT->set_env('search_request', $search_request); - } - $OUTPUT->set_env('search_mods', rcmail_search_mods()); if (!empty($_SESSION['search_scope'])) @@ -357,8 +346,6 @@ if (!in_array('threads', $a_show_cols)) array_unshift($a_show_cols, 'threads'); - $_SESSION['skin_path'] = $RCMAIL->config->get('skin_path'); - // set client env $OUTPUT->add_gui_object('messagelist', $attrib['id']); $OUTPUT->set_env('autoexpand_threads', intval($RCMAIL->config->get('autoexpand_threads'))); @@ -401,6 +388,7 @@ $head_replace = true; } + $delimiter = $RCMAIL->storage->get_hierarchy_delimiter(); $search_set = $RCMAIL->storage->get_search_set(); $multifolder = $search_set && $search_set[1]->multi; @@ -491,8 +479,16 @@ $cont = show_bytes($header->$col); else if ($col == 'date') $cont = $RCMAIL->format_date($header->date); - else if ($col == 'folder') - $cont = rcube::Q(rcube_charset::convert($header->folder, 'UTF7-IMAP')); + else if ($col == 'folder') { + if ($last_folder !== $header->folder) { + $last_folder = $header->folder; + $last_folder_name = rcube_charset::convert($last_folder, 'UTF7-IMAP'); + $last_folder_name = $RCMAIL->localize_foldername($last_folder_name, true); + $last_folder_name = str_replace($delimiter, " \xC2\xBB ", $last_folder_name); + } + + $cont = rcube::Q($last_folder_name); + } else $cont = rcube::Q($header->$col); @@ -543,8 +539,6 @@ { global $RCMAIL; - $skin_path = $_SESSION['skin_path']; - // check to see if we have some settings for sorting $sort_col = $_SESSION['sort_col']; $sort_order = $_SESSION['sort_order']; @@ -566,7 +560,7 @@ $onclick = 'return ' . rcmail_output::JS_OBJECT_NAME . ".command('menu-open', 'messagelistmenu', this, event)"; $inner = $RCMAIL->gettext('listoptions'); if (is_string($attrib['optionsmenuicon']) && $attrib['optionsmenuicon'] != 'true') { - $inner = html::img(array('src' => $skin_path . $attrib['optionsmenuicon'], 'alt' => $RCMAIL->gettext('listoptions'))); + $inner = html::img(array('src' => $RCMAIL->output->abs_url($attrib['optionsmenuicon'], true), 'alt' => $RCMAIL->gettext('listoptions'))); } $list_menu = html::a(array( 'href' => '#list-options', @@ -819,7 +813,7 @@ $wash_opts = array( 'show_washed' => false, 'allow_remote' => $p['safe'], - 'blocked_src' => "./program/resources/blocked.gif", + 'blocked_src' => 'program/resources/blocked.gif', 'charset' => RCUBE_CHARSET, 'cid_map' => $cid_replaces, 'html_elements' => array('body'), @@ -1191,7 +1185,23 @@ // unsupported (e.g. encrypted) if ($part->realtype) { if ($part->realtype == 'multipart/encrypted' || $part->realtype == 'application/pkcs7-mime') { - $out .= html::span('part-notice', $RCMAIL->gettext('encryptedmessage')); + if (!empty($_SESSION['browser_caps']['pgpmime']) && $part->realtype == 'multipart/encrypted') { + // find the encrypted message payload part + foreach ($MESSAGE->mime_parts as $mime_id => $mpart) { + if ($mpart->mimetype == 'application/octet-stream' || !empty($mpart->filename)) { + $out .= html::span('part-notice', $RCMAIL->gettext('externalmessagedecryption')); + $OUTPUT->set_env('pgp_mime_part', $mime_id); + $OUTPUT->set_env('pgp_mime_container', '#' . $attrib['id']); + $OUTPUT->add_label('loadingdata'); + $MESSAGE->encrypted_part = $mime_id; + break; + } + } + } + + if (!$MESSAGE->encrypted_part) { + $out .= html::span('part-notice', $RCMAIL->gettext('encryptedmessage')); + } } continue; } @@ -1223,6 +1233,11 @@ // message is cached but not exists (#1485443), or other error if ($body === false) { rcmail_message_error($MESSAGE->uid); + } + + // check if the message body is PGP encrypted + if (strpos($body, 'BEGIN PGP MESSAGE') !== false) { + $OUTPUT->set_env('is_pgp_content', '#' . $attrib['id']); } $plugin = $RCMAIL->plugins->exec_hook('message_body_prefix', @@ -1623,7 +1638,7 @@ rcmail_output::JS_OBJECT_NAME, rcube::JQ($string)), ), html::img(array( - 'src' => $RCMAIL->config->get('skin_path') . $addicon, + 'src' => $RCMAIL->output->abs_url($addicon, true), 'alt' => "Add contact", ))); } @@ -1963,9 +1978,16 @@ // Fixes some content-type names function rcmail_fix_mimetype($name) { + $map = array( + 'image/x-ms-bmp' => 'image/bmp', // #1490282 + ); + + if ($alias = $map[strtolower($name)]) { + $name = $alias; + } // Some versions of Outlook create garbage Content-Type: // application/pdf.A520491B_3BF7_494D_8855_7FAC2C6C0608 - if (preg_match('/^application\/pdf.+/', $name)) { + else if (preg_match('/^application\/pdf.+/', $name)) { $name = 'application/pdf'; } // treat image/pjpeg (image/pjpg, image/jpg) as image/jpeg (#1489097) @@ -2044,7 +2066,7 @@ $select_filter->add($RCMAIL->gettext('priority').': '.$RCMAIL->gettext('low'), 'HEADER X-PRIORITY 4'); $select_filter->add($RCMAIL->gettext('priority').': '.$RCMAIL->gettext('lowest'), 'HEADER X-PRIORITY 5'); - $out = $select_filter->show($_SESSION['search_filter']); + $out = $select_filter->show($_REQUEST['_search'] ? $_SESSION['search_filter'] : 'ALL'); $RCMAIL->output->add_gui_object('search_filter', $attrib['id']); -- Gitblit v1.9.1