From fb28d7fe977519c3f00ccb7fa6ffdd757c0d286e Mon Sep 17 00:00:00 2001 From: A Sigalas Date: Tue, 28 Feb 2017 12:16:53 +0000 Subject: [PATCH 1/2] Fix multibyte bug on utf-8 import --- importexport/inc/class.importexport_import_ui.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/importexport/inc/class.importexport_import_ui.inc.php b/importexport/inc/class.importexport_import_ui.inc.php index 839bca30f8..4a36fbf42c 100644 --- a/importexport/inc/class.importexport_import_ui.inc.php +++ b/importexport/inc/class.importexport_import_ui.inc.php @@ -74,7 +74,9 @@ use EGroupware\Api\Etemplate; $plugin = new $definition_obj->plugin; // Check file encoding matches import - $sample = file_get_contents($content['file']['tmp_name'],false, null, 0, 1024); + $sample = file_get_contents($content['file']['tmp_name']); + $sample = mb_substr( $sample, 1024 ); + if($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard') { $preference = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; From 1dac0eb700c192d6b8247d5d246c29cfc15e35b7 Mon Sep 17 00:00:00 2001 From: A Sigalas Date: Tue, 28 Feb 2017 12:46:12 +0000 Subject: [PATCH 2/2] Get sample without fetching the whole file, fix netbeans potential error --- importexport/inc/class.importexport_import_ui.inc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/importexport/inc/class.importexport_import_ui.inc.php b/importexport/inc/class.importexport_import_ui.inc.php index 4a36fbf42c..f4462bfce0 100644 --- a/importexport/inc/class.importexport_import_ui.inc.php +++ b/importexport/inc/class.importexport_import_ui.inc.php @@ -74,8 +74,7 @@ use EGroupware\Api\Etemplate; $plugin = new $definition_obj->plugin; // Check file encoding matches import - $sample = file_get_contents($content['file']['tmp_name']); - $sample = mb_substr( $sample, 1024 ); + $sample = mb_substr(file_get_contents($content['file']['tmp_name'], false, null, 0, 2048), 1024); if($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard') {