From 9796cd2063770a8562d58d6492fd6904cdeb4627 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 02 May 2016 12:01:18 -0400
Subject: [PATCH] Merge branch 'dev-rfc822-preview'

---
 program/steps/mail/viewsource.inc |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/program/steps/mail/viewsource.inc b/program/steps/mail/viewsource.inc
index 1e1fe26..6dab45c 100644
--- a/program/steps/mail/viewsource.inc
+++ b/program/steps/mail/viewsource.inc
@@ -5,7 +5,7 @@
  | program/steps/mail/viewsource.inc                                     |
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
- | Copyright (C) 2005-2013, The Roundcube Dev Team                       |
+ | Copyright (C) 2005-2016, The Roundcube Dev Team                       |
  |                                                                       |
  | Licensed under the GNU General Public License version 3 or            |
  | any later version with exceptions for skins & plugins.                |
@@ -27,7 +27,15 @@
 
 // similar code as in program/steps/mail/get.inc
 if ($uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET)) {
-    $headers = $RCMAIL->storage->get_message_headers($uid);
+    if ($pos = strpos($uid, '.')) {
+        $message = new rcube_message($uid);
+        $headers = $message->headers;
+        $part_id = substr($uid, $pos + 1);
+    }
+    else {
+        $headers = $RCMAIL->storage->get_message_headers($uid);
+    }
+
     $charset = $headers->charset ?: $RCMAIL->config->get('default_charset');
 
     header("Content-Type: text/plain; charset={$charset}");
@@ -46,7 +54,12 @@
         header("Content-Disposition: attachment; filename=\"$filename\"");
     }
 
-    $RCMAIL->storage->print_raw_body($uid, empty($_GET['_save']));
+    if (isset($message)) {
+        $message->get_part_body($part_id, empty($_GET['_save']), 0, -1);
+    }
+    else {
+        $RCMAIL->storage->print_raw_body($uid, empty($_GET['_save']));
+    }
 }
 else {
     rcube::raise_error(array(

--
Gitblit v1.9.1