Changeset 5366 in subversion


Ignore:
Timestamp:
Oct 26, 2011 7:48:27 AM (19 months ago)
Author:
thomasb
Message:

Backporting changes trom trunk (r5357-r5365)

Location:
branches/release-0.7/program
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/release-0.7/program/include/rcube_imap.php

    r5347 r5366  
    15091509                if (is_array($a_index)) 
    15101510                    sort($a_index); 
    1511             } else if ($max = $this->_messagecount($mailbox)) { 
     1511            } else if ($max = $this->_messagecount($mailbox, 'ALL', true, false)) { 
    15121512                $a_index = range(1, $max); 
    15131513            } 
     
    16951695 
    16961696        if ($orig_criteria == 'ALL') { 
    1697             $max = $this->_messagecount($mailbox); 
     1697            $max = $this->_messagecount($mailbox, 'ALL', true, false); 
    16981698            $a_messages = $max ? range(1, $max) : array(); 
    16991699        } 
     
    19621962 
    19631963        $headers = $this->get_headers($uid, $mailbox); 
     1964 
     1965        // message doesn't exist? 
     1966        if (empty($headers)) 
     1967            return null;  
    19641968 
    19651969        // structure might be cached 
     
    23212325        // decode filename 
    23222326        if (!empty($filename_mime)) { 
    2323             $part->filename = rcube_imap::decode_mime_string($filename_mime, 
    2324                 $part->charset ? $part->charset : ($this->struct_charset ? $this->struct_charset : 
    2325                 rc_detect_encoding($filename_mime, $this->default_charset))); 
     2327            if (!empty($part->charset)) 
     2328                $charset = $part->charset; 
     2329            else if (!empty($this->struct_charset)) 
     2330                $charset = $this->struct_charset; 
     2331            else 
     2332                $charset = rc_detect_encoding($filename_mime, $this->default_charset); 
     2333 
     2334            $part->filename = rcube_imap::decode_mime_string($filename_mime, $charset); 
    23262335        } 
    23272336        else if (!empty($filename_encoded)) { 
     
    23312340                $filename_encoded = $fmatches[2]; 
    23322341            } 
     2342 
    23332343            $part->filename = rcube_charset_convert(urldecode($filename_encoded), $filename_charset); 
    23342344        } 
     
    23672377    function &get_message_part($uid, $part=1, $o_part=NULL, $print=NULL, $fp=NULL, $skip_charset_conv=false) 
    23682378    { 
    2369         // get part encoding if not provided 
     2379        // get part data if not provided 
    23702380        if (!is_object($o_part)) { 
    23712381            $structure = $this->conn->getStructure($this->mailbox, $uid, true); 
     2382            $part_data = rcube_imap_generic::getStructurePartData($structure, $part); 
    23722383 
    23732384            $o_part = new rcube_message_part; 
    2374             $o_part->ctype_primary = strtolower(rcube_imap_generic::getStructurePartType($structure, $part)); 
    2375             $o_part->encoding      = strtolower(rcube_imap_generic::getStructurePartEncoding($structure, $part)); 
    2376             $o_part->charset       = rcube_imap_generic::getStructurePartCharset($structure, $part); 
    2377         } 
    2378  
    2379         // TODO: Add caching for message parts 
    2380  
    2381         if (!$part) { 
    2382             $part = 'TEXT'; 
    2383         } 
    2384  
    2385         $body = $this->conn->handlePartBody($this->mailbox, $uid, true, $part, 
    2386             $o_part->encoding, $print, $fp); 
     2385            $o_part->ctype_primary = $part_data['type']; 
     2386            $o_part->encoding      = $part_data['encoding']; 
     2387            $o_part->charset       = $part_data['charset']; 
     2388            $o_part->size          = $part_data['size']; 
     2389        } 
     2390 
     2391        if ($o_part && $o_part->size) { 
     2392            $body = $this->conn->handlePartBody($this->mailbox, $uid, true, 
     2393                $part ? $part : 'TEXT', $o_part->encoding, $print, $fp); 
     2394        } 
    23872395 
    23882396        if ($fp || $print) { 
     
    23982406                if (!$o_part->charset || strtoupper($o_part->charset) == 'US-ASCII') { 
    23992407                    // try to extract charset information from HTML meta tag (#1488125) 
    2400                     if ($o_part->ctype_secondary == 'html' && preg_match('/<meta[^>]+charset=([a-z0-9-]+)/i', $body, $m)) 
     2408                    if ($o_part->ctype_secondary == 'html' && preg_match('/<meta[^>]+charset=([a-z0-9-_]+)/i', $body, $m)) 
    24012409                        $o_part->charset = strtoupper($m[1]); 
    24022410                    else 
  • branches/release-0.7/program/include/rcube_imap_cache.php

    r5286 r5366  
    854854        if ($is_thread) { 
    855855            // check messages number... 
    856             if ($mbox_data['EXISTS'] != @max(array_keys($index['depth']))) { 
     856            if (!$this->skip_deleted && $mbox_data['EXISTS'] != @max(array_keys($index['depth']))) { 
    857857                return false; 
    858858            } 
  • branches/release-0.7/program/include/rcube_imap_generic.php

    r5330 r5366  
    23942394        $result = false; 
    23952395 
     2396        if ($a[2] != 'FETCH') { 
     2397        } 
    23962398        // handle empty "* X FETCH ()" response 
    2397         if ($line[$len-1] == ')' && $line[$len-2] != '(') { 
     2399        else if ($line[$len-1] == ')' && $line[$len-2] != '(') { 
    23982400            // one line response, get everything between first and last quotes 
    23992401            if (substr($line, -4, 3) == 'NIL') { 
     
    31753177    } 
    31763178 
    3177     static function getStructurePartType($structure, $part) 
     3179    /** 
     3180     * Returns data of a message part according to specified structure. 
     3181     * 
     3182     * @param array  $structure Message structure (getStructure() result) 
     3183     * @param string $part      Message part identifier 
     3184     * 
     3185     * @return array Part data as hash array (type, encoding, charset, size) 
     3186     */ 
     3187    static function getStructurePartData($structure, $part) 
    31783188    { 
    31793189            $part_a = self::getStructurePartArray($structure, $part); 
    3180             if (!empty($part_a)) { 
    3181                     if (is_array($part_a[0])) 
    3182                 return 'multipart'; 
    3183                     else if ($part_a[0]) 
    3184                 return $part_a[0]; 
    3185             } 
    3186  
    3187         return 'other'; 
    3188     } 
    3189  
    3190     static function getStructurePartEncoding($structure, $part) 
    3191     { 
    3192             $part_a = self::getStructurePartArray($structure, $part); 
    3193             if ($part_a) { 
    3194                     if (!is_array($part_a[0])) 
    3195                 return $part_a[5]; 
    3196             } 
    3197  
    3198         return ''; 
    3199     } 
    3200  
    3201     static function getStructurePartCharset($structure, $part) 
    3202     { 
    3203             $part_a = self::getStructurePartArray($structure, $part); 
    3204             if ($part_a) { 
    3205                     if (is_array($part_a[0])) 
    3206                 return ''; 
    3207                     else { 
    3208                             if (is_array($part_a[2])) { 
    3209                                     $name = ''; 
    3210                                     while (list($key, $val) = each($part_a[2])) 
    3211                         if (strcasecmp($val, 'charset') == 0) 
    3212                             return $part_a[2][$key+1]; 
    3213                             } 
    3214                     } 
    3215             } 
    3216  
    3217         return ''; 
     3190            $data   = array(); 
     3191 
     3192            if (empty($part_a)) { 
     3193            return $data; 
     3194        } 
     3195 
     3196        // content-type 
     3197        if (is_array($part_a[0])) { 
     3198            $data['type'] = 'multipart'; 
     3199        } 
     3200        else { 
     3201            $data['type'] = strtolower($part_a[0]); 
     3202 
     3203            // encoding 
     3204            $data['encoding'] = strtolower($part_a[5]); 
     3205 
     3206            // charset 
     3207            if (is_array($part_a[2])) { 
     3208               while (list($key, $val) = each($part_a[2])) { 
     3209                    if (strcasecmp($val, 'charset') == 0) { 
     3210                        $data['charset'] = $part_a[2][$key+1]; 
     3211                        break; 
     3212                    } 
     3213                } 
     3214            } 
     3215        } 
     3216 
     3217        // size 
     3218        $data['size'] = intval($part_a[6]); 
     3219 
     3220        return $data; 
    32183221    } 
    32193222 
     
    32483251    } 
    32493252 
    3250  
    32513253    /** 
    32523254     * Creates next command identifier (tag) 
  • branches/release-0.7/program/steps/mail/func.inc

    r5266 r5366  
    560560  $html_search = array( 
    561561    '/(<\/nobr>)(\s+)(<nobr>)/i',       // space(s) between <NOBR> 
    562     '/<title[^>]*>.*<\/title>/i',       // PHP bug #32547 workaround: remove title tag 
     562    '/<title[^>]*>[^<]*<\/title>/i',    // PHP bug #32547 workaround: remove title tag 
    563563    '/^(\0\0\xFE\xFF|\xFF\xFE\0\0|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/',    // byte-order mark (only outlook?) 
    564564    '/<html\s[^>]+>/i',                 // washtml/DOMDocument cannot handle xml namespaces 
     
    591591 
    592592  // charset was converted to UTF-8 in rcube_imap::get_message_part(), 
    593   // -> change charset specification in HTML accordingly 
    594   $charset_pattern = '(<meta\s+[^>]*content=)[\'"]?(\w+\/\w+;\s*charset=)([a-z0-9-_]+[\'"]?)'; 
    595   if (preg_match("/$charset_pattern/Ui", $html)) { 
    596     $html = preg_replace("/$charset_pattern/i", '\\1"\\2'.RCMAIL_CHARSET.'"', $html); 
    597   } 
    598   else { 
    599     // add meta content-type to malformed messages, washtml cannot work without that 
    600     if (!preg_match('/<head[^>]*>(.*)<\/head>/Uims', $html)) 
    601       $html = '<head></head>'. $html; 
    602     $html = substr_replace($html, '<meta http-equiv="Content-Type" content="text/html; charset='.RCMAIL_CHARSET.'" />', intval(stripos($html, '<head>')+6), 0); 
     593  // change/add charset specification in HTML accordingly, 
     594  // washtml cannot work without that 
     595  $meta = '<meta http-equiv="Content-Type" content="text/html; charset='.RCMAIL_CHARSET.'" />'; 
     596 
     597  // remove old meta tag and add the new one, making sure 
     598  // that it is placed in the head (#1488093) 
     599  $html = preg_replace('/<meta[^>]+charset=[a-z0-9-_]+[^>]*>/Ui', '', $html); 
     600  $html = preg_replace('/(<head[^>]*>)/Ui', '\\1'.$meta, $html, -1, $rcount); 
     601  if (!$rcount) { 
     602    $html = '<head>' . $meta . '</head>' . $html; 
    603603  } 
    604604 
  • branches/release-0.7/program/steps/settings/func.inc

    r5297 r5366  
    179179    if (!isset($no_override['timezone'])) { 
    180180      $field_id = 'rcmfd_timezone'; 
    181       $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id, 'onchange' => "document.getElementById('rcmfd_dst').disabled=this.selectedIndex==0")); 
     181      $select_timezone = new html_select(array('name' => '_timezone', 'id' => $field_id, 'onchange' => "$('#rcmfd_dst').attr('disabled', this.selectedIndex==0)")); 
    182182      $select_timezone->add(rcube_label('autodetect'), 'auto'); 
    183183      $select_timezone->add('(GMT -11:00) Midway Island, Samoa', '-11'); 
Note: See TracChangeset for help on using the changeset viewer.