From a0530a6ec0cb464ec6eaa63fd211c2ffbe6db9ad Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sun, 08 Jun 2008 14:17:09 -0400
Subject: [PATCH] - option to disable autocompletion from selected LDAP address books (#1484922

---
 program/include/rcube_imap.php |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php
index 43c3117..9d8f6d3 100644
--- a/program/include/rcube_imap.php
+++ b/program/include/rcube_imap.php
@@ -1074,7 +1074,7 @@
       $struct->ctype_primary = 'multipart';
       
       // find first non-array entry
-      for ($i=1; count($part); $i++)
+      for ($i=1; $i<count($part); $i++)
         if (!is_array($part[$i]))
           {
           $struct->ctype_secondary = strtolower($part[$i]);
@@ -1085,7 +1085,7 @@
 
       $struct->parts = array();
       for ($i=0, $count=0; $i<count($part); $i++)
-        if (is_array($part[$i]) && count($part[$i]) > 5)
+        if (is_array($part[$i]) && count($part[$i]) > 3)
           $struct->parts[] = $this->_structure_part($part[$i], ++$count, $struct->mime_id);
           
       return $struct;
@@ -1159,10 +1159,13 @@
       if (is_array($part[8]) && empty($struct->parts))
         $struct->parts[] = $this->_structure_part($part[8], ++$count, $struct->mime_id);
       }
-      
+
     // normalize filename property
     if ($filename_mime = $struct->d_parameters['filename'] ? $struct->d_parameters['filename'] : $struct->ctype_parameters['name'])
-      $struct->filename = rcube_imap::decode_mime_string($filename_mime, $this->default_charset);
+    {
+      $struct->filename = rcube_imap::decode_mime_string($filename_mime, 
+    	    $struct->charset ? $struct->charset : rc_detect_encoding($filename_mime, $this->default_charset));
+    }
     else if ($filename_encoded = $struct->d_parameters['filename*'] ? $struct->d_parameters['filename*'] : $struct->ctype_parameters['name*'])
     {
       // decode filename according to RFC 2231, Section 4
@@ -1170,7 +1173,8 @@
       $struct->filename = rcube_charset_convert(urldecode($filename_urlencoded), $filename_charset);
     }
     else if (!empty($struct->headers['content-description']))
-      $struct->filename = rcube_imap::decode_mime_string($struct->headers['content-description'], $this->default_charset);
+      $struct->filename = rcube_imap::decode_mime_string($struct->headers['content-description'],
+    	    $struct->charset ? $struct->charset : rc_detect_encoding($struct->headers['content-description'],$this->default_charset));
       
     return $struct;
     }

--
Gitblit v1.9.1