Skip to content

Fix "Maximum function nesting level" #1468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions src/PhpSpreadsheet/Reader/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,27 +242,26 @@ function ($sum, $value) use ($median) {
*/
private function getNextLine($line = '')
{
// Get the next line in the file
$newLine = fgets($this->fileHandle);
do {
// Get the next line in the file
$newLine = fgets($this->fileHandle);

// Return false if there is no next line
if ($newLine === false) {
return false;
}
// Return false if there is no next line
if ($newLine === false) {
return false;
}

// Add the new line to the line passed in
$line = $line . $newLine;
// Add the new line to the line passed in
$line = $line . $newLine;

// Drop everything that is enclosed to avoid counting false positives in enclosures
$enclosure = '(?<!' . preg_quote($this->escapeCharacter, '/') . ')'
. preg_quote($this->enclosure, '/');
$line = preg_replace('/(' . $enclosure . '.*' . $enclosure . ')/Us', '', $line);
// Drop everything that is enclosed to avoid counting false positives in enclosures
$enclosure = '(?<!' . preg_quote($this->escapeCharacter, '/') . ')'
. preg_quote($this->enclosure, '/');
$line = preg_replace('/(' . $enclosure . '.*' . $enclosure . ')/Us', '', $line);

// See if we have any enclosures left in the line
// if we still have an enclosure then we need to read the next line as well
if (preg_match('/(' . $enclosure . ')/', $line) > 0) {
$line = $this->getNextLine($line);
}
// See if we have any enclosures left in the line
// if we still have an enclosure then we need to read the next line as well
} while (preg_match('/(' . $enclosure . ')/', $line) > 0);

return $line;
}
Expand Down