Changeset d310537 in github


Ignore:
Timestamp:
Apr 11, 2011 8:24:00 AM (2 years ago)
Author:
alecpl <alec@…>
Children:
8ffd08a
Parents:
382b8b1
Message:
  • Apply fixes from trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r382b8b1 rd310537  
    22=========================== 
    33 
     4- Support 'abort' and 'result' response in 'preferences_save' hook, add error handling 
     5- Fix bug where some content would cause hang on html2text conversion (#1487863) 
     6- Improve space-stuffing handling in format=flowed messages (#1487861) 
     7- Fix bug where some dates would produce SQL error in MySQL (#1487856) 
     8- Added workaround for some IMAP server with broken STATUS response (#1487859) 
     9- Fix bug where default_charset was not used for text messages (#1487836) 
    410- Stateless request tokens. No keep-alive necessary on login page (#1487829) 
    511- PEAR::Net_SMTP 1.5.1 
  • plugins/managesieve/localization/pl_PL.inc

    r62a83b3 rd310537  
    4949$labels['filterset'] = 'Zbiór filtrów'; 
    5050$labels['filtersetadd'] = 'Dodaj zbiór filtrów'; 
    51 $labels['filtersetdel'] = 'Usuń bierzÄ 
     51$labels['filtersetdel'] = 'Usuń bieŌĠ
    5252cy zbiór filtrów'; 
    53 $labels['filtersetact'] = 'Aktywuj bierzÄ 
     53$labels['filtersetact'] = 'Aktywuj bieŌĠ
    5454cy zbiór filtrów'; 
    55 $labels['filtersetdeact'] = 'Deaktywuj bierzÄ 
     55$labels['filtersetdeact'] = 'Deaktywuj bieŌĠ
    5656cy zbiór filtrów'; 
    57 $labels['filtersetget'] = 'Pobierz bierzÄ 
     57$labels['filtersetget'] = 'Pobierz bieŌĠ
    5858cy zbiór filtrów w formacie tekstowym'; 
    5959$labels['filterdef'] = 'Definicja filtra'; 
  • program/include/rcube_imap.php

    r2430846 rd310537  
    24272427     * @param  mixed              $print  True to print part, ressource to write part contents in 
    24282428     * @param  resource           $fp     File pointer to save the message part 
     2429     * @param  boolean            $skip_charset_conv Disables charset conversion 
     2430     * 
    24292431     * @return string Message/part body if not printed 
    24302432     */ 
    2431     function &get_message_part($uid, $part=1, $o_part=NULL, $print=NULL, $fp=NULL) 
     2433    function &get_message_part($uid, $part=1, $o_part=NULL, $print=NULL, $fp=NULL, $skip_charset_conv=false) 
    24322434    { 
    24332435        // get part encoding if not provided 
     
    24592461        } 
    24602462 
    2461         // convert charset (if text or message part) and part's charset is specified 
    2462         if ($body && $o_part->charset 
    2463             && preg_match('/^(text|message)$/', $o_part->ctype_primary) 
     2463        // convert charset (if text or message part) 
     2464        if ($body && !$skip_charset_conv && 
     2465            preg_match('/^(text|message)$/', $o_part->ctype_primary) 
    24642466        ) { 
     2467            if (!$o_part->charset || strtoupper($o_part->charset) == 'US-ASCII') { 
     2468                $o_part->charset = $this->default_charset; 
     2469            } 
    24652470            $body = rcube_charset_convert($body, $o_part->charset); 
    24662471        } 
  • program/include/rcube_imap_generic.php

    r5228a55 rd310537  
    965965            list($mbox, $items) = $this->tokenizeResponse($response, 2); 
    966966 
     967            // Fix for #1487859. Some buggy server returns not quoted 
     968            // folder name with spaces. Let's try to handle this situation 
     969            if (!is_array($items) && ($pos = strpos($response, '(')) !== false) { 
     970                $response = substr($response, $pos); 
     971                $items = $this->tokenizeResponse($response, 1); 
     972                if (!is_array($items)) { 
     973                    return $result; 
     974                } 
     975            } 
     976 
    967977            for ($i=0, $len=count($items); $i<$len; $i += 2) { 
    968978                $result[$items[$i]] = (int) $items[$i+1]; 
     
    15701580                    $str = $matches[1]; 
    15711581 
    1572                     // swap parents with quotes, then explode 
    1573                     $str = preg_replace('/[()]/', '"', $str); 
    1574                     $a = rcube_explode_quoted_string(' ', $str); 
    1575  
    1576                     // did we get the right number of replies? 
    1577                     $parts_count = count($a); 
    1578                     if ($parts_count>=6) { 
    1579                         for ($i=0; $i<$parts_count; $i=$i+2) { 
    1580                             if ($a[$i] == 'UID') { 
    1581                                 $result[$id]->uid = intval($a[$i+1]); 
    1582                             } 
    1583                             else if ($a[$i] == 'RFC822.SIZE') { 
    1584                                 $result[$id]->size = intval($a[$i+1]); 
    1585                             } 
    1586                             else if ($a[$i] == 'INTERNALDATE') { 
    1587                                 $time_str = $a[$i+1]; 
    1588                             } 
    1589                             else if ($a[$i] == 'FLAGS') { 
    1590                                 $flags_str = $a[$i+1]; 
    1591                             } 
     1582                    while (list($name, $value) = $this->tokenizeResponse($str, 2)) { 
     1583                        if ($name == 'UID') { 
     1584                            $result[$id]->uid = intval($value); 
    15921585                        } 
    1593  
    1594                         $time_str = str_replace('"', '', $time_str); 
    1595  
    1596                         // if time is gmt... 
    1597                         $time_str = str_replace('GMT','+0000',$time_str); 
    1598  
    1599                         $result[$id]->internaldate = $time_str; 
    1600                         $result[$id]->timestamp    = $this->StrToTime($time_str); 
    1601                         $result[$id]->date         = $time_str; 
     1586                        else if ($name == 'RFC822.SIZE') { 
     1587                            $result[$id]->size = intval($value); 
     1588                        } 
     1589                        else if ($name == 'INTERNALDATE') { 
     1590                            $result[$id]->internaldate = $value; 
     1591                            $result[$id]->date         = $value; 
     1592                            $result[$id]->timestamp    = $this->StrToTime($value); 
     1593                        } 
     1594                        else if ($name == 'FLAGS') { 
     1595                            $flags_a = $value; 
     1596                        } 
    16021597                    } 
    16031598 
     
    16471642                    // handle FLAGS reply after headers (AOL, Zimbra?) 
    16481643                    if (preg_match('/\s+FLAGS \((.*)\)\)$/', $line, $matches)) { 
    1649                         $flags_str = $matches[1]; 
     1644                        $flags_a = $this->tokenizeResponse($matches[1]); 
    16501645                        break; 
    16511646                    } 
     
    16711666                    // create array with header field:data 
    16721667                    while (list($lines_key, $str) = each($lines)) { 
    1673                         list($field, $string) = $this->splitHeaderLine($str); 
     1668                        list($field, $string) = explode(':', $str, 2); 
    16741669 
    16751670                        $field  = strtolower($field); 
    1676                         $string = preg_replace('/\n\s*/', ' ', $string); 
     1671                        $string = preg_replace('/\n[\t\s]*/', ' ', trim($string)); 
    16771672 
    16781673                        switch ($field) { 
     
    17381733 
    17391734                // process flags 
    1740                 if (!empty($flags_str)) { 
    1741                     $flags_str = preg_replace('/[\\\"]/', '', $flags_str); 
    1742                     $flags_a   = explode(' ', $flags_str); 
    1743  
    1744                     if (is_array($flags_a)) { 
    1745                         foreach($flags_a as $flag) { 
    1746                             $flag = strtoupper($flag); 
    1747                             if ($flag == 'SEEN') { 
    1748                                 $result[$id]->seen = true; 
    1749                             } else if ($flag == 'DELETED') { 
    1750                                 $result[$id]->deleted = true; 
    1751                             } else if ($flag == 'RECENT') { 
    1752                                 $result[$id]->recent = true; 
    1753                             } else if ($flag == 'ANSWERED') { 
    1754                                 $result[$id]->answered = true; 
    1755                             } else if ($flag == '$FORWARDED') { 
    1756                                 $result[$id]->forwarded = true; 
    1757                             } else if ($flag == 'DRAFT') { 
    1758                                 $result[$id]->is_draft = true; 
    1759                             } else if ($flag == '$MDNSENT') { 
    1760                                 $result[$id]->mdn_sent = true; 
    1761                             } else if ($flag == 'FLAGGED') { 
    1762                                  $result[$id]->flagged = true; 
    1763                             } 
     1735                if (!empty($flags_a)) { 
     1736                    foreach ($flags_a as $flag) { 
     1737                        $flag = str_replace('\\', '', $flag); 
     1738                        $result[$id]->flags[] = $flag; 
     1739 
     1740                        switch (strtoupper($flag)) { 
     1741                        case 'SEEN': 
     1742                            $result[$id]->seen = true; 
     1743                            break; 
     1744                        case 'DELETED': 
     1745                            $result[$id]->deleted = true; 
     1746                            break; 
     1747                        case 'ANSWERED': 
     1748                            $result[$id]->answered = true; 
     1749                            break; 
     1750                        case '$FORWARDED': 
     1751                            $result[$id]->forwarded = true; 
     1752                            break; 
     1753                        case '$MDNSENT': 
     1754                            $result[$id]->mdn_sent = true; 
     1755                            break; 
     1756                        case 'FLAGGED': 
     1757                            $result[$id]->flagged = true; 
     1758                            break; 
    17641759                        } 
    1765                         $result[$id]->flags = $flags_a; 
    17661760                    } 
    17671761                } 
     
    32983292        // support non-standard "GMTXXXX" literal 
    32993293        $date = preg_replace('/GMT\s*([+-][0-9]+)/', '\\1', $date); 
     3294 
    33003295        // if date parsing fails, we have a date in non-rfc format. 
    33013296        // remove token from the end and try again 
    3302         while ((($ts = @strtotime($date))===false) || ($ts < 0)) { 
     3297        while (($ts = intval(@strtotime($date))) <= 0) { 
    33033298            $d = explode(' ', $date); 
    33043299            array_pop($d); 
     
    33123307 
    33133308        return $ts < 0 ? 0 : $ts; 
    3314     } 
    3315  
    3316     private function splitHeaderLine($string) 
    3317     { 
    3318         $pos = strpos($string, ':'); 
    3319         if ($pos>0) { 
    3320             $res[0] = substr($string, 0, $pos); 
    3321             $res[1] = trim(substr($string, $pos+1)); 
    3322             return $res; 
    3323         } 
    3324         return $string; 
    33253309    } 
    33263310 
  • program/include/rcube_mdb2.php

    r9db4ca9 rd310537  
    554554    function fromunixtime($timestamp) 
    555555    { 
    556         switch($this->db_provider) { 
    557             case 'mysqli': 
    558             case 'mysql': 
    559             case 'sqlite': 
    560                 return sprintf("FROM_UNIXTIME(%d)", $timestamp); 
    561  
    562             default: 
    563                 return date("'Y-m-d H:i:s'", $timestamp); 
    564         } 
     556        return date("'Y-m-d H:i:s'", $timestamp); 
    565557    } 
    566558 
  • program/include/rcube_message.php

    r99897b7 rd310537  
    726726                } 
    727727                else if ($line) { 
    728                     $line = ' ' . rc_wordwrap(rtrim($line), $length - 2, " \r\n "); 
     728                    $line = rc_wordwrap(rtrim($line), $length - 2, " \r\n"); 
     729                    // space-stuffing 
     730                    $line = preg_replace('/(^|\r\n)(From| |>)/', '\\1 \\2', $line); 
    729731                } 
    730732 
  • program/js/app.js

    r98cb0f1 rd310537  
    29952995  { 
    29962996    // check input fields 
    2997     var value_to = $("[name='_to']").val(); 
    2998     var value_cc = $("[name='_cc']").val(); 
    2999     var value_bcc = $("[name='_bcc']").val(); 
    3000     var value_subject = $("[name='_subject']").val(); 
    3001     var str = ''; 
     2997    var ed, str = '', 
     2998      value_to = $("[name='_to']").val(), 
     2999      value_cc = $("[name='_cc']").val(), 
     3000      value_bcc = $("[name='_bcc']").val(), 
     3001      value_subject = $("[name='_subject']").val(); 
    30023002 
    30033003    if (value_to) 
     
    30103010      str += value_subject+':'; 
    30113011 
    3012     var editor = tinyMCE.get(this.env.composebody); 
    3013     if (editor) 
    3014       str += editor.getContent(); 
     3012    if (window.tinyMCE && (ed = tinyMCE.get(this.env.composebody))) 
     3013      str += ed.getContent(); 
    30153014    else 
    30163015      str += $("[name='_message']").val(); 
     
    46234622 
    46244623      if ((current_li = this.get_folder_li(old, prefix))) { 
    4625         $(current_li).removeClass('selected').removeClass('unfocused'); 
     4624        $(current_li).removeClass('selected').addClass('unfocused'); 
    46264625      } 
    46274626      if ((target_li = this.get_folder_li(name, prefix))) { 
  • program/lib/html2text.php

    r2430846 rd310537  
    573573    function _convert_pre(&$text) 
    574574    { 
     575        // get the content of PRE element 
    575576        while (preg_match('/<pre[^>]*>(.*)<\/pre>/ismU', $text, $matches)) { 
    576             $result = preg_replace($this->pre_search, $this->pre_replace, $matches[1]); 
    577             $text = preg_replace('/<pre[^>]*>.*<\/pre>/ismU', '<div><br>' . $result . '<br></div>', $text, 1); 
     577            // convert the content 
     578            $this->pre_content = sprintf('<div><br>%s<br></div>', 
     579                preg_replace($this->pre_search, $this->pre_replace, $matches[1])); 
     580            // replace the content (use callback because content can contain $0 variable) 
     581            $text = preg_replace_callback('/<pre[^>]*>.*<\/pre>/ismU',  
     582                array('html2text', '_preg_pre_callback'), $text, 1); 
     583            // free memory 
     584            $this->pre_content = ''; 
    578585        } 
    579586    } 
     
    640647     *  @param  array PREG matches 
    641648     *  @return string 
    642      *  @access private 
    643      */ 
    644     function _preg_callback($matches) 
     649     */ 
     650    private function _preg_callback($matches) 
    645651    { 
    646652        switch($matches[1]) { 
     
    660666 
    661667    /** 
     668     *  Callback function for preg_replace_callback use in PRE content handler. 
     669     * 
     670     *  @param  array PREG matches 
     671     *  @return string 
     672     */ 
     673    private function _preg_pre_callback($matches) 
     674    { 
     675        return $this->pre_content; 
     676    } 
     677 
     678    /** 
    662679     *  Strtoupper multibyte wrapper function 
    663680     * 
    664681     *  @param  string 
    665682     *  @return string 
    666      *  @access private 
    667      */ 
    668     function _strtoupper($str) 
     683     */ 
     684    private function _strtoupper($str) 
    669685    { 
    670686        if (function_exists('mb_strtoupper')) 
  • program/steps/mail/func.inc

    r2430846 rd310537  
    727727 
    728728  // split body into single lines 
    729   $a_lines = preg_split('/\r?\n/', $body); 
     729  $body = preg_split('/\r?\n/', $body); 
    730730  $quote_level = 0; 
    731731  $last = -1; 
    732732 
    733733  // find/mark quoted lines... 
    734   for ($n=0, $cnt=count($a_lines); $n < $cnt; $n++) { 
    735     if ($a_lines[$n][0] == '>' && preg_match('/^(>+\s*)+/', $a_lines[$n], $regs)) { 
     734  for ($n=0, $cnt=count($body); $n < $cnt; $n++) { 
     735    if ($body[$n][0] == '>' && preg_match('/^(>+\s*)+/', $body[$n], $regs)) { 
    736736      $q = strlen(preg_replace('/\s/', '', $regs[0])); 
    737       $a_lines[$n] = substr($a_lines[$n], strlen($regs[0])); 
    738  
    739       if ($q > $quote_level) 
    740         $a_lines[$n] = $replacer->get_replacement($replacer->add( 
    741           str_repeat('<blockquote>', $q - $quote_level))) . $a_lines[$n]; 
    742       else if ($q < $quote_level) 
    743         $a_lines[$n] = $replacer->get_replacement($replacer->add( 
    744           str_repeat('</blockquote>', $quote_level - $q))) . $a_lines[$n]; 
     737      $body[$n] = substr($body[$n], strlen($regs[0])); 
     738 
     739      if ($q > $quote_level) { 
     740        $body[$n] = $replacer->get_replacement($replacer->add( 
     741          str_repeat('<blockquote>', $q - $quote_level))) . $body[$n]; 
     742      } 
     743      else if ($q < $quote_level) { 
     744        $body[$n] = $replacer->get_replacement($replacer->add( 
     745          str_repeat('</blockquote>', $quote_level - $q))) . $body[$n]; 
     746      } 
    745747      else if ($flowed) { 
    746748        // previous line is flowed 
    747         if (isset($a_lines[$last]) && $a_lines[$n] 
    748           && $a_lines[$last][strlen($a_lines[$last])-1] == ' ') { 
     749        if (isset($body[$last]) && $body[$n] 
     750          && $body[$last][strlen($body[$last])-1] == ' ') { 
    749751          // merge lines 
    750           $a_lines[$last] .= $a_lines[$n]; 
    751           unset($a_lines[$n]); 
     752          $body[$last] .= $body[$n]; 
     753          unset($body[$n]); 
    752754        } 
    753         else 
     755        else { 
    754756          $last = $n; 
     757        } 
    755758      } 
    756759    } 
     
    759762      if ($flowed) { 
    760763        // sig separator - line is fixed 
    761         if ($a_lines[$n] == '-- ') { 
    762           $last = $n; 
     764        if ($body[$n] == '-- ') { 
     765          $last = $last_sig = $n; 
    763766        } 
    764767        else { 
    765768          // remove space-stuffing 
    766           if ($a_lines[$n][0] == ' ') 
    767             $a_lines[$n] = substr($a_lines[$n], 1); 
     769          if ($body[$n][0] == ' ') 
     770            $body[$n] = substr($body[$n], 1); 
    768771 
    769772          // previous line is flowed? 
    770           if (isset($a_lines[$last]) && $a_lines[$n] 
    771             && $a_lines[$last] != '-- ' 
    772             && $a_lines[$last][strlen($a_lines[$last])-1] == ' ' 
     773          if (isset($body[$last]) && $body[$n] 
     774            && $last != $last_sig 
     775            && $body[$last][strlen($body[$last])-1] == ' ' 
    773776          ) { 
    774             $a_lines[$last] .= $a_lines[$n]; 
    775             unset($a_lines[$n]); 
     777            $body[$last] .= $body[$n]; 
     778            unset($body[$n]); 
    776779          } 
    777780          else { 
     
    780783        } 
    781784        if ($quote_level > 0) 
    782           $a_lines[$last] = $replacer->get_replacement($replacer->add( 
    783             str_repeat('</blockquote>', $quote_level))) . $a_lines[$last]; 
     785          $body[$last] = $replacer->get_replacement($replacer->add( 
     786            str_repeat('</blockquote>', $quote_level))) . $body[$last]; 
    784787      } 
    785788      else if ($quote_level > 0) 
    786         $a_lines[$n] = $replacer->get_replacement($replacer->add( 
    787           str_repeat('</blockquote>', $quote_level))) . $a_lines[$n]; 
     789        $body[$n] = $replacer->get_replacement($replacer->add( 
     790          str_repeat('</blockquote>', $quote_level))) . $body[$n]; 
    788791    } 
    789792 
     
    791794  } 
    792795 
    793   $body = join("\n", $a_lines); 
     796  $body = join("\n", $body); 
    794797 
    795798  // quote plain text (don't use Q() here, to display entities "as is") 
  • program/steps/settings/save_prefs.inc

    r98cb0f1 rd310537  
    9898} 
    9999 
    100 $data = rcmail::get_instance()->plugins->exec_hook('preferences_save', 
     100$plugin = rcmail::get_instance()->plugins->exec_hook('preferences_save', 
    101101  array('prefs' => $a_user_prefs, 'section' => $CURR_SECTION)); 
    102102 
    103 $a_user_prefs = $data['prefs']; 
     103$a_user_prefs = $plugin['prefs']; 
    104104 
    105105// don't override these parameters 
     
    160160} 
    161161 
    162 if ($USER->save_prefs($a_user_prefs)) 
     162// Save preferences 
     163if (!$plugin['abort']) 
     164  $saved = $USER->save_prefs($a_user_prefs); 
     165else 
     166  $saved = $plugin['result']; 
     167 
     168if ($saved) 
    163169  $OUTPUT->show_message('successfullysaved', 'confirmation'); 
     170else 
     171  $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error'); 
    164172 
    165173// display the form again 
    166174rcmail_overwrite_action('edit-prefs'); 
    167175 
    168  
Note: See TracChangeset for help on using the changeset viewer.