Skip to content

Commit

Permalink
Remove BOM when parsing file; fixes pluginsGLPI#74
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne authored and stonebuzz committed Aug 3, 2018
1 parent 28d0d97 commit 31f01dd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions inc/backendcsv.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ function getNumberOfLines() {
function openFile() {

$this->file_handler = fopen($this->file, 'r');

// Check if file starts with BOM.
// 1. If BOM found, keep the handler moved to 4th char to not include it in data.
// 2. If no BOM found, rewind to start of file.
$hasBOM = fread($this->file_handler, 3) === pack('CCC', 0xEF, 0xBB, 0xBF);
if (!$hasBOM) {
fseek($this->file_handler, 0);
}
}


Expand Down

0 comments on commit 31f01dd

Please sign in to comment.