From 2965a981b7ec22866fbdf2d567d87e2d068d3617 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Fri, 31 Jul 2015 16:04:08 -0400
Subject: [PATCH] Allow to search and import missing PGP pubkeys from keyservers using Publickey.js

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

diff --git a/program/lib/Roundcube/rcube_charset.php b/program/lib/Roundcube/rcube_charset.php
index 3657626..048961a 100644
--- a/program/lib/Roundcube/rcube_charset.php
+++ b/program/lib/Roundcube/rcube_charset.php
@@ -753,7 +753,7 @@
 
         // iconv/mbstring are much faster (especially with long strings)
         if (function_exists('mb_convert_encoding')) {
-            $msch = mb_substitute_character('none');
+            $msch = mb_substitute_character();
             mb_substitute_character('none');
             $res = mb_convert_encoding($input, 'UTF-8', 'UTF-8');
             mb_substitute_character($msch);
@@ -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