From 5740b10bf8cdb82f795d88e1f020440c8dae4acb Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Thu, 16 Jan 2014 03:04:34 -0500
Subject: [PATCH] Merge branch 'master' of github.com:roundcube/roundcubemail

---
 CHANGELOG                                     |    1 +
 program/lib/Roundcube/rcube_result_thread.php |   35 +++++++++++++++++++++--------------
 program/lib/Roundcube/html.php                |    4 ++--
 3 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index f45bb04..6beb463 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix compatibility with PHP 5.2 in html.php file (#1489514)
 - Remove expand/collapse with plus/minus keys (on numeric keypad) (#1489513)
 - Fix issue where filesystem path was added to all-attachments (zip) file (#1489507)
 - Fix case-sensitivity of email addresses handling on compose (#1485499)
diff --git a/program/lib/Roundcube/html.php b/program/lib/Roundcube/html.php
index 587b030..33517fb 100644
--- a/program/lib/Roundcube/html.php
+++ b/program/lib/Roundcube/html.php
@@ -880,7 +880,7 @@
     private function _row_tagname()
     {
         static $row_tagnames = array('table' => 'tr', 'ul' => 'li', '*' => 'div');
-        return $row_tagnames[$this->tagname] ?: $row_tagnames['*'];
+        return $row_tagnames[$this->tagname] ? $row_tagnames[$this->tagname] : $row_tagnames['*'];
     }
 
     /**
@@ -889,7 +889,7 @@
     private function _col_tagname()
     {
         static $col_tagnames = array('table' => 'td', '*' => 'span');
-        return $col_tagnames[$this->tagname] ?: $col_tagnames['*'];
+        return $col_tagnames[$this->tagname] ? $col_tagnames[$this->tagname] : $col_tagnames['*'];
     }
 
 }
diff --git a/program/lib/Roundcube/rcube_result_thread.php b/program/lib/Roundcube/rcube_result_thread.php
index 7657550..c7f21db 100644
--- a/program/lib/Roundcube/rcube_result_thread.php
+++ b/program/lib/Roundcube/rcube_result_thread.php
@@ -606,33 +606,39 @@
         // arrays handling is much more expensive
         // For the following structure: THREAD (2)(3 6 (4 23)(44 7 96))
         // -- 2
-        //
         // -- 3
         //     \-- 6
         //         |-- 4
         //         |    \-- 23
         //         |
         //         \-- 44
-        //              \-- 7
-        //                   \-- 96
+        //               \-- 7
+        //                    \-- 96
         //
         // The output will be: 2,3^1:6^2:4^3:23^2:44^3:7^4:96
 
         if ($str[$begin] != '(') {
-            $stop = $begin + strspn($str, '1234567890', $begin, $end - $begin);
-            $msg  = substr($str, $begin, $stop - $begin);
-            if (!$msg) {
+            // find next bracket
+            $stop      = $begin + strcspn($str, '()', $begin, $end - $begin);
+            $messages  = explode(' ', trim(substr($str, $begin, $stop - $begin)));
+
+            if (empty($messages)) {
                 return $node;
             }
 
-            $this->meta['messages']++;
-
-            $node .= ($depth ? self::SEPARATOR_ITEM.$depth.self::SEPARATOR_LEVEL : '').$msg;
-
-            if ($stop + 1 < $end) {
-                $node .= $this->parse_thread($str, $stop + 1, $end, $depth + 1);
+            foreach ($messages as $msg) {
+                if ($msg) {
+                    $node .= ($depth ? self::SEPARATOR_ITEM.$depth.self::SEPARATOR_LEVEL : '').$msg;
+                    $this->meta['messages']++;
+                    $depth++;
+                }
             }
-        } else {
+
+            if ($stop < $end) {
+                $node .= $this->parse_thread($str, $stop, $end, $depth);
+            }
+        }
+        else {
             $off = $begin;
             while ($off < $end) {
                 $start = $off;
@@ -649,7 +655,8 @@
                     if ($p1 !== false && $p1 < $p) {
                         $off = $p1 + 1;
                         $n++;
-                    } else {
+                    }
+                    else {
                         $off = $p + 1;
                         $n--;
                     }

--
Gitblit v1.9.1