From d1b540ddd33a8b04c2f97083457e056cc6449703 Mon Sep 17 00:00:00 2001 From: Ignace Nyamagana Butera Date: Mon, 3 Oct 2016 13:55:39 +0200 Subject: [PATCH] bug fix BOM stripping #184 --- CHANGELOG.md | 18 ++++++++++++++++++ src/Modifier/QueryFilter.php | 2 +- test/ReaderTest.php | 1 - 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67b30bef..295bbd10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ All Notable changes to `Csv` will be documented in this file +## Next + +### Added + +- None + +### Deprecated + +- None + +### Fixed + +- BOM filtering fix [issue #184](ttps://github.com/thephpleague/csv/issues/184) + +### Removed + +- None + ## 8.1.1 - 2016-09-05 ### Added diff --git a/src/Modifier/QueryFilter.php b/src/Modifier/QueryFilter.php index 532105bc..582440c9 100644 --- a/src/Modifier/QueryFilter.php +++ b/src/Modifier/QueryFilter.php @@ -222,7 +222,7 @@ protected function getStripBomIterator(Iterator $iterator) } $row[0] = mb_substr($row[0], $bom_length); - if ($row[0][0] === $enclosure && mb_substr($row[0], -1, 1) === $enclosure) { + if (mb_substr($row[0], 0, 1) === $enclosure && mb_substr($row[0], -1, 1) === $enclosure) { $row[0] = mb_substr($row[0], 1, -1); } diff --git a/test/ReaderTest.php b/test/ReaderTest.php index 1637b2a5..27515c53 100644 --- a/test/ReaderTest.php +++ b/test/ReaderTest.php @@ -395,7 +395,6 @@ public function testEach() $transform = []; $this->csv->addFilter(function ($row) { return $row != [null]; - }); $res = $this->csv->each(function ($row) use (&$transform) { $transform[] = array_map('strtoupper', $row);