From 8f3dc270a6a6068b7a0489b334eb41eeb6a4ce1d Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Fri, 27 Jul 2012 22:06:28 +0100 Subject: [PATCH] Bugfix: Work Item 18415- mb_stripos empty delimiter --- Classes/PHPExcel/Calculation/TextData.php | 12 +++++++++--- changelog.txt | 2 +- unitTests/rawTestData/Calculation/TextData/FIND.data | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Classes/PHPExcel/Calculation/TextData.php b/Classes/PHPExcel/Calculation/TextData.php index aceafc63..3c3ed22a 100644 --- a/Classes/PHPExcel/Calculation/TextData.php +++ b/Classes/PHPExcel/Calculation/TextData.php @@ -239,9 +239,12 @@ class PHPExcel_Calculation_TextData { $haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); } - if (($offset > 0) && (strlen($haystack) > $offset)) { + if (($offset > 0) && (PHPExcel_Shared_String::CountCharacters($haystack) > $offset)) { + if (PHPExcel_Shared_String::CountCharacters($needle) == 0) { + return $offset; + } if (function_exists('mb_strpos')) { - $pos = mb_strpos($haystack, $needle, --$offset,'UTF-8'); + $pos = mb_strpos($haystack, $needle, --$offset, 'UTF-8'); } else { $pos = strpos($haystack, $needle, --$offset); } @@ -272,7 +275,10 @@ class PHPExcel_Calculation_TextData { $haystack = ($haystack) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); } - if (($offset > 0) && (strlen($haystack) > $offset)) { + if (($offset > 0) && (PHPExcel_Shared_String::CountCharacters($haystack) > $offset)) { + if (PHPExcel_Shared_String::CountCharacters($needle) == 0) { + return $offset; + } if (function_exists('mb_stripos')) { $pos = mb_stripos($haystack, $needle, --$offset,'UTF-8'); } else { diff --git a/changelog.txt b/changelog.txt index 6d0c51bc..c8ab3613 100644 --- a/changelog.txt +++ b/changelog.txt @@ -92,7 +92,7 @@ Fixed in develop branch: - Bugfix: (MBaker) Various fixes to Chart handling - Bugfix: (MBaker) Work item 18370 - Error loading xlsx file with column breaks - Bugfix: (MBaker) OOCalc Reader now handles percentage and currency data types -- Bugfix: (MBaker) OOCalc Reader modified to process number-rows-repeated +- Bugfix: (MBaker) Work Item 18415- mb_stripos empty delimiter 2012-05-19 (v1.7.7): diff --git a/unitTests/rawTestData/Calculation/TextData/FIND.data b/unitTests/rawTestData/Calculation/TextData/FIND.data index 677d4f0d..411150da 100644 --- a/unitTests/rawTestData/Calculation/TextData/FIND.data +++ b/unitTests/rawTestData/Calculation/TextData/FIND.data @@ -9,3 +9,5 @@ "k", "Mark Baker", 5, 8 "a", "Mark Baker", 3, 7 "BITE", "BIT", "#VALUE!" +"", "Mark Baker", 1 +"", "Mark Baker", 8, 8