From f94a801d038fbc5278a32cbde7c1cfffb6f3779c Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Wed, 16 Apr 2008 02:17:32 -0400
Subject: [PATCH] - Fix typo in set_charset() (#1484991)

---
 program/steps/mail/func.inc |   49 +++++++++++++++++++++++++++++++------------------
 1 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index b1ce4bd..b75b115 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -19,7 +19,6 @@
 
 */
 
-require_once('lib/html2text.inc');
 require_once('lib/enriched.inc');
 require_once('include/rcube_smtp.inc');
 
@@ -408,30 +407,43 @@
   if (!$attrib['id'])
     $attrib['id'] = 'rcmquotadisplay';
 
+  if(isset($attrib['display']))
+    $_SESSION['quota_display'] = $attrib['display'];
+
   $OUTPUT->add_gui_object('quotadisplay', $attrib['id']);
 
   // allow the following attributes to be added to the <span> tag
-  $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
+  $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'display'));
 
   $out = '<span' . $attrib_str . '>';
-  $out .= rcmail_quota_content($attrib['display']);
+  $out .= rcmail_quota_content();
   $out .= '</span>';
   return $out;
   }
 
 
-function rcmail_quota_content($display)
+function rcmail_quota_content($quota=NULL)
   {
   global $IMAP, $COMM_PATH;
 
-  if (!$IMAP->get_capability('QUOTA'))
-    $quota_text = rcube_label('unknown');
-  else if ($quota = $IMAP->get_quota())
+  $display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : '';
+
+  if (is_array($quota) && !empty($quota['used']) && !empty($quota['total']))
     {
-    $quota_text = sprintf("%s / %s (%.0f%%)",
-                          show_bytes($quota["used"] * 1024),
-                          show_bytes($quota["total"] * 1024),
-                          $quota["percent"]);
+      if (!isset($quota['percent']))
+        $quota['percent'] = $quota['used'] / $quota['total'];
+    }
+  elseif (!$IMAP->get_capability('QUOTA'))
+    return rcube_label('unknown');
+  else
+    $quota = $IMAP->get_quota();
+
+  if ($quota)
+    {
+    $quota_text = sprintf('%s / %s (%.0f%%)',
+                          show_bytes($quota['used'] * 1024),
+                          show_bytes($quota['total'] * 1024),
+                          $quota['percent']);
 
     // show quota as image (by Brett Patterson)
     if ($display == 'image' && function_exists('imagegif'))
@@ -679,8 +691,8 @@
     $convert_patterns[] = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/ie';
     $convert_replaces[] = "rcmail_str_replacement('<a href=\"mailto:\\1\" onclick=\"return ".JS_OBJECT_NAME.".command(\'compose\',\'\\1\',this)\">\\1</a>', \$replace_strings)";
     
-    if ($part->ctype_parameters['format'] != 'flowed')
-      $body = wordwrap(trim($body), 80);
+//    if ($part->ctype_parameters['format'] != 'flowed')
+//      $body = wordwrap(trim($body), 80);
 
     $body = preg_replace($convert_patterns, $convert_replaces, $body);
 
@@ -695,10 +707,10 @@
       $quotation = '';
       $q = 0;
       
-      if (preg_match('/^(>+\s*)/', $line, $regs))
+      if (preg_match('/^(>+\s*)+/', $line, $regs))
         {
-        $q = strlen(preg_replace('/\s/', '', $regs[1]));
-        $line = substr($line, strlen($regs[1]));
+        $q    = strlen(preg_replace('/\s/', '', $regs[0]));
+        $line = substr($line, strlen($regs[0]));
 
         if ($q > $quote_level)
           $quotation = str_repeat('<blockquote>', $q - $quote_level);
@@ -1127,7 +1139,8 @@
 
   // add comments arround html and other tags
   $out = preg_replace(array(
-      '/(<!DOCTYPE.+)/i',
+      '/(<!DOCTYPE[^>]*>)/i',
+      '/(<\?xml[^>]*>)/i',
       '/(<\/?html[^>]*>)/i',
       '/(<\/?head[^>]*>)/i',
       '/(<title[^>]*>.*<\/title>)/Ui',
@@ -1528,7 +1541,7 @@
   'messagecontentframe' => 'rcmail_messagecontent_frame',
   'messagepartframe' => 'rcmail_message_part_frame',
   'messagepartcontrols' => 'rcmail_message_part_controls',
-  'searchform' => 'rcmail_search_form'
+  'searchform' => array($OUTPUT, 'search_form'),
 ));
 
 ?>

--
Gitblit v1.9.1