changeset 12:5039cc34571f

some old, mostly new 7.3->8.4 changes needed
author Charlie Root
date Thu, 28 Aug 2025 10:37:42 -0400
parents aff04b06b685
children cfac0673464e
files program/lib/Roundcube/rcube_charset.php program/lib/Roundcube/rcube_config.php program/lib/Roundcube/rcube_imap_generic.php program/lib/Roundcube/rcube_result_thread.php program/lib/Roundcube/rcube_vcard.php
diffstat 5 files changed, 19 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/program/lib/Roundcube/rcube_charset.php	Sun Jan 26 13:09:03 2025 -0500
+++ b/program/lib/Roundcube/rcube_charset.php	Thu Aug 28 10:37:42 2025 -0400
@@ -220,7 +220,7 @@
         }
         // UTF
         else if (preg_match('/U[A-Z][A-Z](7|8|16|32)(BE|LE)*/', $str, $m)) {
-            $result = 'UTF-' . $m[1] . $m[2];
+	  $result = 'UTF-' . $m[1] . (isset($m[2]) ? $m2 : '') ;
         }
         // ISO-8859
         else if (preg_match('/ISO8859([0-9]{0,2})/', $str, $m)) {
@@ -337,8 +337,8 @@
                 'ISO-2022-JP'  => 'ISO-2022-JP-MS',
             );
 
-            $mb_from = $aliases[$from] ?: $from;
-            $mb_to   = $aliases[$to] ?: $to;
+            $mb_from = $aliases[$from] ?? $from;
+            $mb_to   = $aliases[$to] ?? $to;
 
             // Do the same as //IGNORE with iconv
             mb_substitute_character('none');
--- a/program/lib/Roundcube/rcube_config.php	Sun Jan 26 13:09:03 2025 -0500
+++ b/program/lib/Roundcube/rcube_config.php	Thu Aug 28 10:37:42 2025 -0400
@@ -322,7 +322,7 @@
                     $success = true;
                 }
                 // deprecated name of config variable
-                if (is_array($rcmail_config)) {
+                if (isset($rcmail_config) && is_array($rcmail_config)) {
                     $this->merge($rcmail_config);
                     $success = true;
                 }
--- a/program/lib/Roundcube/rcube_imap_generic.php	Sun Jan 26 13:09:03 2025 -0500
+++ b/program/lib/Roundcube/rcube_imap_generic.php	Thu Aug 28 10:37:42 2025 -0400
@@ -394,8 +394,10 @@
      */
     protected function closeSocket()
     {
-        @fclose($this->fp);
-        $this->fp = null;
+            if ($this->fp) {
+	      fclose($this->fp);
+	      $this->fp = null;
+	    }
     }
 
     /**
@@ -3899,14 +3901,19 @@
 
         $result = array();
         $start  = $prev = $messages[0];
-	$needStrip = (strpos($start,'_') !== false);	  
+	$needStrip = (! is_numeric($start)) || (! is_numeric($prev));	  
 
         foreach ($messages as $id) {
-	    #rcube::write_log('mail',"non-num? id: |$id|, prev: |$prev|");
             #Advanced search calls with pseudo-message-ids?  Non-numeric, anyway, e.g.
 	    # 420__MB__97ce7451bd364b47894f71ba7eb8ceb1
 	    if ($needStrip) {
+	      set_error_handler(function($e1, $e2) {
+		                 #rcube::write_log('mail',
+				     "non-num? id: |$id|, prev: |$prev|");
+		                 },
+		E_WARNING);
 	      $incr = substr($id,0,strpos($id,'_')) - substr($prev,0,strpos($prev,'_'));
+	      restore_error_handler();
 	    }
 	    else {
 	      $incr = $id - $prev;
--- a/program/lib/Roundcube/rcube_result_thread.php	Sun Jan 26 13:09:03 2025 -0500
+++ b/program/lib/Roundcube/rcube_result_thread.php	Thu Aug 28 10:37:42 2025 -0400
@@ -493,8 +493,9 @@
         $result  = array();
         $start   = 0;
 
-        while (($pos = @strpos($this->raw_data, self::SEPARATOR_ELEMENT, $start))
-            || ($start < $datalen && ($pos = $datalen))
+        while ($start < $datalen && 
+               (($pos = @strpos($this->raw_data, self::SEPARATOR_ELEMENT, $start)) != false
+            ||  ($pos = $datalen))
         ) {
             $len   = $pos - $start;
             $elem  = substr($this->raw_data, $start, $len);
--- a/program/lib/Roundcube/rcube_vcard.php	Sun Jan 26 13:09:03 2025 -0500
+++ b/program/lib/Roundcube/rcube_vcard.php	Thu Aug 28 10:37:42 2025 -0400
@@ -536,7 +536,7 @@
                 '/^item\d*\.X-AB.*$/mi',  // remove cruft like item1.X-AB*
                 '/^item\d*\./mi',         // remove item1.ADR instead of ADR
                 '/\n+/',                 // remove empty lines
-                '/^(N:[^;\R]*)$/m',      // if N doesn't have any semicolons, add some
+                '/^(N:[^;\n\r]*)$/m',      // if N doesn't have any semicolons, add some
             ),
             array(
                 '\2;type=\5\3:\4',