From 966a9086a54c5f5b98158d21797b167b6e13b332 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 05 May 2015 07:49:04 -0400
Subject: [PATCH] Fix rcube_charset::clean() for case when mbstring and iconv are not installed

---
 program/lib/Roundcube/rcube_charset.php |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/program/lib/Roundcube/rcube_charset.php b/program/lib/Roundcube/rcube_charset.php
index 3657626..d8750a0 100644
--- a/program/lib/Roundcube/rcube_charset.php
+++ b/program/lib/Roundcube/rcube_charset.php
@@ -789,30 +789,29 @@
 
             // 1-byte character
             if ($ord <= 0x7F) {
-                if ($seq) {
+                if ($seq !== '') {
                     $out .= preg_match($regexp, $seq) ? $seq : '';
+                    $seq = '';
                 }
-                $seq = '';
+
                 $out .= $chr;
             }
-            // first (or second) byte of multibyte sequence
+            // first byte of multibyte sequence
             else if ($ord >= 0xC0) {
-                if (strlen($seq) > 1) {
+                if ($seq !== '') {
                     $out .= preg_match($regexp, $seq) ? $seq : '';
                     $seq = '';
                 }
-                else if ($seq && ord($seq) < 0xC0) {
-                    $seq = '';
-                }
-                $seq .= $chr;
+
+                $seq = $chr;
             }
             // next byte of multibyte sequence
-            else if ($seq) {
+            else if ($seq !== '') {
                 $seq .= $chr;
             }
         }
 
-        if ($seq) {
+        if ($seq !== '') {
             $out .= preg_match($regexp, $seq) ? $seq : '';
         }
 

--
Gitblit v1.9.1