From 15fee7b8dd9991c798e6b3eeb9f98cd34e8153fc Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 30 Sep 2005 15:38:27 -0400
Subject: [PATCH] Moved config files to config/*inc.php.dist

---
 program/lib/Mail/mime.php       |   85 ++++++++++++++++++++----------------------
 index.php                       |    4 +-
 config/db.inc.php.dist          |    0 
 config/main.inc.php.dist        |    0 
 program/lib/Mail/mimeDecode.php |   13 ++----
 program/lib/Mail/mimePart.php   |    2 
 6 files changed, 47 insertions(+), 57 deletions(-)

diff --git a/config/db.inc.php b/config/db.inc.php.dist
similarity index 100%
rename from config/db.inc.php
rename to config/db.inc.php.dist
diff --git a/config/main.inc.php b/config/main.inc.php.dist
similarity index 100%
rename from config/main.inc.php
rename to config/main.inc.php.dist
diff --git a/index.php b/index.php
index bdccd37..b7fbe67 100644
--- a/index.php
+++ b/index.php
@@ -3,10 +3,10 @@
 /*
  +-----------------------------------------------------------------------+
  | RoundCube Webmail IMAP Client                                         |
- | Version 0.1-20050811                                                  |
+ | Version 0.1-20050929                                                  |
  |                                                                       |
  | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
- | All rights reserved.                                                  |
+ | Licensed under the GNU GPL                                            |
  |                                                                       |
  | Redistribution and use in source and binary forms, with or without    |
  | modification, are permitted provided that the following conditions    |
diff --git a/program/lib/Mail/mime.php b/program/lib/Mail/mime.php
index da43d15..48bd5f5 100644
--- a/program/lib/Mail/mime.php
+++ b/program/lib/Mail/mime.php
@@ -3,7 +3,7 @@
 // +-----------------------------------------------------------------------+
 // | Copyright (c) 2002-2003  Richard Heyes                                |
 // | Copyright (c) 2003-2005  The PHP Group                                |
-// | Licensed under the GNU GPL                                            |
+// | All rights reserved.                                                  |
 // |                                                                       |
 // | Redistribution and use in source and binary forms, with or without    |
 // | modification, are permitted provided that the following conditions    |
@@ -51,8 +51,8 @@
  *   in the mime_mail.class by Tobias Ratschiller <tobias@dnet.it> and
  *   Sascha Schumann <sascha@schumann.cx>
  *
- *   Function _encodeHeaders() changed by Thomas Bruederli <roundcube@gmail.com>
- *   in order to be read correctly by Google Gmail
+ * @notes Replaced method _encodeHeaders by the version of ed@avi.ru
+ *        See http://pear.php.net/bugs/bug.php?id=30 for details
  *
  * @author   Richard Heyes <richard.heyes@heyes-computing.net>
  * @author   Tomas V.V.Cox <cox@idecnet.com>
@@ -119,6 +119,7 @@
         $this->_build_params = array(
                                      'text_encoding' => '7bit',
                                      'html_encoding' => 'quoted-printable',
+                                     'header_encoding' => 'quoted-printable',
                                      '7bit_wrap'     => 998,
                                      'html_charset'  => 'ISO-8859-1',
                                      'text_charset'  => 'ISO-8859-1',
@@ -292,7 +293,12 @@
         if (!$fd = fopen($file_name, 'rb')) {
             return PEAR::raiseError('Could not open ' . $file_name);
         }
-        $cont = fread($fd, filesize($file_name));
+        $filesize = filesize($file_name);
+        if ($filesize == 0){
+            $cont =  "";
+        }else{
+            $cont = fread($fd, $filesize);
+        }
         fclose($fd);
         return $cont;
     }
@@ -463,9 +469,9 @@
 
         if (!empty($this->_html_images) AND isset($this->_htmlbody)) {
             foreach ($this->_html_images as $value) {
-                $regex = '#src\s*=\s*(["\']?)' . preg_quote($value['name']) .
-                         '(["\'])?#';
-                $rep = 'src=\1cid:' . $value['cid'] .'\2';
+                $regex = '#(\s)((?i)src|background|href(?-i))\s*=\s*(["\']?)' . preg_quote($value['name'], '#') .
+                         '\3#';
+                $rep = '\1\2=\3cid:' . $value['cid'] .'\3';
                 $this->_htmlbody = preg_replace($regex, $rep,
                                        $this->_htmlbody
                                    );
@@ -665,53 +671,42 @@
     }
 
     /**
-     * Encodes a header as per RFC2047
-     *
-     * @param  string  $input The header data to encode
-     * @return string  Encoded data
-     * @access private
-     */
+    * Encodes a header as per RFC2047
+    *
+    * @param  string  $input The header data to encode
+    * @return string         Encoded data
+    * @access private
+    */
     function _encodeHeaders($input)
     {
-    $enc_prefix = '=?' . $this->_build_params['head_charset'] . '?Q?';
         foreach ($input as $hdr_name => $hdr_value) {
-            if (preg_match('/(\w*[\x80-\xFF]+\w*)/', $hdr_value)) {
-                $enc_value = preg_replace('/([\x80-\xFF])/e', '"=".strtoupper(dechex(ord("\1")))', $hdr_value);
-                // check for <email address> in string
-                if (preg_match('/<[a-z0-9\-\.\+\_]+@[a-z0-9]([a-z0-9\-].?)*[a-z0-9]\\.[a-z]{2,5}>/i', $enc_value) && ($p = strrpos($enc_value, '<'))) {
-                    $hdr_value = $enc_prefix . substr($enc_value, 0, $p-1) . '?= ' . substr($enc_value, $p, strlen($enc_value)-$p);
-                } else {
-                    $hdr_value = $enc_prefix . $enc_value . '?=';
-                }
-            }
-            $input[$hdr_name] = $hdr_value;
-        }
-
-        return $input;
-    }
-
-    /* replaced 2005/07/08 by roundcube@gmail.com
-    
-    function _encodeHeaders_old($input)
-    {
-        foreach ($input as $hdr_name => $hdr_value) {
-            preg_match_all('/(\w*[\x80-\xFF]+\w*)/', $hdr_value, $matches);
+            preg_match_all('/([\w\-]*[\x80-\xFF]+[\w\-]*(\s+[\w\-]*[\x80-\xFF]+[\w\-]*)*)\s*/',
+            $hdr_value, $matches);
             foreach ($matches[1] as $value) {
-                $replacement = preg_replace('/([\x80-\xFF])/e',
-                                            '"=" .
-                                            strtoupper(dechex(ord("\1")))',
-                                            $value);
-                $hdr_value = str_replace($value, '=?' .
-                                         $this->_build_params['head_charset'] .
-                                         '?Q?' . $replacement . '?=',
-                                         $hdr_value);
+                switch ($head_encoding = $this->_build_params['head_encoding']) {
+                case 'base64':
+                    $symbol = 'B';
+                    $replacement = base64_encode($value);
+                    break;
+
+                default:
+                    if ($head_encoding != 'quoted-printable') {
+                        PEAR::raiseError('Invalid header encoding specified; using `quoted-printable` instead',
+                                        NULL,
+                                        PEAR_ERROR_TRIGGER,
+                                        E_USER_WARNING);
+                    }
+
+                    $symbol = 'Q';
+                    $replacement = preg_replace('/([\s_=\?\x80-\xFF])/e', '"=" . strtoupper(dechex(ord("\1")))', $value);
+                }
+                $hdr_value = str_replace($value, '=?' . $this->_build_params['head_charset'] . '?' . $symbol . '?' . $replacement . '?=', $hdr_value);
             }
             $input[$hdr_name] = $hdr_value;
         }
-
+        
         return $input;
     }
-    */
 
     /**
      * Set the object's end-of-line and define the constant if applicable
diff --git a/program/lib/Mail/mimeDecode.php b/program/lib/Mail/mimeDecode.php
index 5bcf4fb..07fe88f 100644
--- a/program/lib/Mail/mimeDecode.php
+++ b/program/lib/Mail/mimeDecode.php
@@ -3,7 +3,7 @@
 // +-----------------------------------------------------------------------+
 // | Copyright (c) 2002-2003  Richard Heyes                                |
 // | Copyright (c) 2003-2005  The PHP Group                                |
-// | Licensed under the GNU GPL                                            |
+// | All rights reserved.                                                  |
 // |                                                                       |
 // | Redistribution and use in source and binary forms, with or without    |
 // | modification, are permitted provided that the following conditions    |
@@ -294,8 +294,9 @@
                         $this->_error = 'No boundary found for ' . $content_type['value'] . ' part';
                         return false;
                     }
-                    
+
                     $default_ctype = (strtolower($content_type['value']) === 'multipart/digest') ? 'message/rfc822' : 'text/plain';
+
                     $parts = $this->_boundarySplit($body, $content_type['other']['boundary']);
                     for ($i = 0; $i < count($parts); $i++) {
                         list($part_header, $part_body) = $this->_splitBodyHeader($parts[$i]);
@@ -498,14 +499,8 @@
         }
 
         $tmp = explode('--' . $boundary, $input);
-        $count = count($tmp);
 
-        // when boundaries are set correctly we should have at least 3 parts;
-        // if not, return the last one (tbr)
-        if ($count<3)
-          return array($tmp[$count-1]);
-        
-        for ($i = 1; $i < $count - 1; $i++) {
+        for ($i = 1; $i < count($tmp) - 1; $i++) {
             $parts[] = $tmp[$i];
         }
 
diff --git a/program/lib/Mail/mimePart.php b/program/lib/Mail/mimePart.php
index 45a0052..b429b90 100644
--- a/program/lib/Mail/mimePart.php
+++ b/program/lib/Mail/mimePart.php
@@ -1,7 +1,7 @@
 <?php
 // +-----------------------------------------------------------------------+
 // | Copyright (c) 2002-2003  Richard Heyes                                     |
-// | Licensed under the GNU GPL                                            |
+// | All rights reserved.                                                  |
 // |                                                                       |
 // | Redistribution and use in source and binary forms, with or without    |
 // | modification, are permitted provided that the following conditions    |

--
Gitblit v1.9.1