Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Bug in file PHPExcel/Reader/CSV.php #879

Closed
Verevival opened this issue Apr 12, 2016 · 5 comments
Closed

Bug in file PHPExcel/Reader/CSV.php #879

Verevival opened this issue Apr 12, 2016 · 5 comments

Comments

@Verevival
Copy link

This line redefines the delimiter and the file is not read correctly
protected function checkSeparator()
{
...
$this->delimiter = substr($line, 4, 1); // line 174
}

@MarkBaker
Copy link
Member

In what way does it misread it? What is the separator defined as in your file? What is it being set to?

@MarkBaker
Copy link
Member

If a defined separator line is

sep=;
01234

then

$this->delimiter = substr($line, 4, 1);

should read 1 character from offset 4, which should be ;

@Verevival
Copy link
Author

Not defined separator in file :)
46.zip

@MarkBaker
Copy link
Member

Then the problem isn't with the line that reads $this->delimiter = substr($line, 4, 1); but with any logic that allows it to drop through to that line if no sep=x line exists in the file

@Verevival
Copy link
Author

Perhaps more correctly be so?
protected function checkSeparator()
{
$line = fgets($this->fileHandle);
if ($line === false) {
return;
}
$line = trim($line);
if ((strlen($line) == 5) && (strpos($line, 'sep=') === 0)) {
$this->delimiter = substr($line, 4, 1);
} else {
return $this->skipBOM();
}
}

MarkBaker pushed a commit that referenced this issue Apr 14, 2016
Code logic identifying a defined separator when no separator is explicitly defined
Case-insensitive check when separator is explicitly defined
MarkBaker pushed a commit that referenced this issue Apr 14, 2016
Code logic identifying a defined separator when no separator is explicitly defined
Case-insensitive check when separator is explicitly defined
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants