commit please this patch

Anton Nehoroshih anton@valuehost.ru
Tue, 31 Jul 2001 15:54:14 +0400


to allow using this program with cyrillic encoded mail messages, plase applay this patch
This patch allows to show in letters correctly codings of Russian letters


Index: horde/lib/MIME.php
===================================================================
RCS file: /cvs/horde/horde/lib/MIME.php,v
retrieving revision 1.61
diff -c -r1.61 MIME.php
*** horde/lib/MIME.php  2001/07/13 18:02:20     1.61
--- horde/lib/MIME.php  2001/07/31 11:35:26
***************
*** 125,130 ****
--- 125,131 ----
       */
      function decode($string)
      {
+       global $conf;
          $pos = strpos($string, '=?');
          if ($pos === false) {
              return $string;
***************
*** 166,184 ****
              $encoded_text = str_replace('_', '%20', $encoded_text);
              $encoded_text = str_replace('=', '%', $encoded_text);
              $decoded = urldecode($encoded_text);
!             
!             if (strtolower($charset) == 'windows-1251') {
!                 $decoded = convert_cyr_string($decoded, 'w', 'k');
!             }
              break;
              
          case 'B':
          case 'b':
              $decoded = urldecode(base64_decode($encoded_text));
!             
!             if (strtolower($charset) == 'windows-1251') {
!                 $decoded = convert_cyr_string($decoded, 'w', 'k');
!             }
              break;
              
          default:
--- 167,197 ----
              $encoded_text = str_replace('_', '%20', $encoded_text);
              $encoded_text = str_replace('=', '%', $encoded_text);
              $decoded = urldecode($encoded_text);
!             if (strtolower($conf['lang']['charset'])=='windows-1251') {
!               if (strtolower($charset) == 'koi8-r') {
!                   $decoded = convert_cyr_string($decoded, 'k', 'w');
!               }
!           }
!             if (strtolower($conf['lang']['charset'])=='koi8-r') {
!               if (strtolower($charset) == 'windows-1251') {
!                   $decoded = convert_cyr_string($decoded, 'w', 'k');
!               }
!           }
              break;
              
          case 'B':
          case 'b':
              $decoded = urldecode(base64_decode($encoded_text));
!             if (strtolower($conf['lang']['charset'])=='windows-1251') {
!               if (strtolower($charset) == 'koi8-r') {
!                   $decoded = convert_cyr_string($decoded, 'k', 'w');
!               }
!           }
!             if (strtolower($conf['lang']['charset'])=='koi8-r') {
!               if (strtolower($charset) == 'windows-1251') {
!                   $decoded = convert_cyr_string($decoded, 'w', 'k');
!               }
!           }
              break;
              
          default:
Index: imp/lib/IMP.php
===================================================================
RCS file: /cvs/horde/imp/lib/IMP.php,v
retrieving revision 1.176
diff -c -r1.176 IMP.php
*** imp/lib/IMP.php     2001/07/14 13:30:19     1.176
--- imp/lib/IMP.php     2001/07/31 11:36:14
***************
*** 717,735 ****
       */
      function getDecodedPart($mime)
      {
!         global $imp;
          
          if ($mime->encoding == ENCBASE64) {
!             return imap_base64(imap_fetchbody($imp['stream'], $mime->index, $mime->imap_id, FT_UID));
          } elseif ($mime->encoding == ENCQUOTEDPRINTABLE) {
              $raw = imap_fetchbody($imp['stream'], $mime->index, $mime->imap_id, FT_UID);
              $data = imap_qprint($raw);
              if (empty($data))
                  $data = $raw;
!             return $data;
          } else {
!             return imap_fetchbody($imp['stream'], $mime->index, $mime->imap_id, FT_UID);
          }
      }
    
      /**
--- 717,746 ----
       */
      function getDecodedPart($mime)
      {
!         global $imp,$conf;
          
          if ($mime->encoding == ENCBASE64) {
!             $msg=imap_base64(imap_fetchbody($imp['stream'], $mime->index, $mime->imap_id, FT_UID));
          } elseif ($mime->encoding == ENCQUOTEDPRINTABLE) {
              $raw = imap_fetchbody($imp['stream'], $mime->index, $mime->imap_id, FT_UID);
              $data = imap_qprint($raw);
              if (empty($data))
                  $data = $raw;
!             $msg=$data;
          } else {
!             $msg=imap_fetchbody($imp['stream'], $mime->index, $mime->imap_id, FT_UID);
          }
+       if (strtolower($conf['lang']['charset'])=='windows-1251') {
+           if (strtolower($mime->charset)=='koi8-r') {
+            $msg=convert_cyr_string($msg,'k','w');
+           }
+       }
+       if (strtolower($conf['lang']['charset'])=='koi8-r') {
+           if (strtolower($mime->charset)=='windows-1251') {
+            $msg=convert_cyr_string($msg,'w','k');
+           }
+       }
+       return $msg;
      }
    
      /**