From b79cc545ec020f7dd4bd83dcd06af3cf2b1fcaff Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 28 Aug 2012 05:20:20 -0400
Subject: [PATCH] Improvements/fixes for Larry skin

---
 program/include/rcube_imap_generic.php |   37 +++++++++++++++++--------------------
 1 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index bf97123..915a11a 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -2377,7 +2377,7 @@
         return $this->handlePartBody($mailbox, $id, $is_uid, $part);
     }
 
-    function handlePartBody($mailbox, $id, $is_uid=false, $part='', $encoding=NULL, $print=NULL, $file=NULL)
+    function handlePartBody($mailbox, $id, $is_uid=false, $part='', $encoding=NULL, $print=NULL, $file=NULL, $formatted=true)
     {
         if (!$this->select($mailbox)) {
             return false;
@@ -2494,7 +2494,7 @@
                         continue;
                     $line = convert_uudecode($line);
                 // default
-                } else {
+                } else if ($formatted) {
                     $line = rtrim($line, "\t\r\n\0\x0B") . "\n";
                 }
 
@@ -3202,10 +3202,10 @@
      */
     static function getStructurePartData($structure, $part)
     {
-	    $part_a = self::getStructurePartArray($structure, $part);
-	    $data   = array();
+        $part_a = self::getStructurePartArray($structure, $part);
+        $data   = array();
 
-	    if (empty($part_a)) {
+        if (empty($part_a)) {
             return $data;
         }
 
@@ -3238,13 +3238,13 @@
 
     static function getStructurePartArray($a, $part)
     {
-	    if (!is_array($a)) {
+        if (!is_array($a)) {
             return false;
         }
 
         if (empty($part)) {
-		    return $a;
-	    }
+            return $a;
+        }
 
         $ctype = is_string($a[0]) && is_string($a[1]) ? $a[0] . '/' . $a[1] : '';
 
@@ -3252,20 +3252,17 @@
             $a = $a[8];
         }
 
-	    if (strpos($part, '.') > 0) {
-		    $orig_part = $part;
-		    $pos       = strpos($part, '.');
-		    $rest      = substr($orig_part, $pos+1);
-		    $part      = substr($orig_part, 0, $pos);
+        if (strpos($part, '.') > 0) {
+            $orig_part = $part;
+            $pos       = strpos($part, '.');
+            $rest      = substr($orig_part, $pos+1);
+            $part      = substr($orig_part, 0, $pos);
 
-		    return self::getStructurePartArray($a[$part-1], $rest);
-	    }
+            return self::getStructurePartArray($a[$part-1], $rest);
+        }
         else if ($part > 0) {
-		    if (is_array($a[$part-1]))
-                return $a[$part-1];
-		    else
-                return $a;
-	    }
+            return (is_array($a[$part-1])) ? $a[$part-1] : $a;
+        }
     }
 
     /**

--
Gitblit v1.9.1