PhpSpreadsheet
PhpSpreadsheet copied to clipboard
Incorrect reader used for CSV files with BOM
This is:
- [x] a bug report
What is the expected behavior?
Reading an CSV file with IOFactory::load($file) should use the Csv Reader no matter whether the file starts with a BOM or not. The HTML Reader should do further checks regarding tags after finding a BOM.
What is the current behavior?
The HTML reader checks if the file starts with a BOM and returns true without any further syntax checks.
I think the bug was introduced with this change https://github.com/PHPOffice/PhpSpreadsheet/commit/09c9a310a03f62777c0ce83beae49946fb3984d0#diff-914de62bf54eee4a88135dcbbbce0cf9a59ad5c08b21ac454e645d2bad2390caR151
What are the steps to reproduce?
- Create a CSV file starting with a BOM.
- Try to load the file with
IOFactory::load($file)
see my test in https://github.com/PHPOffice/PhpSpreadsheet/pull/4029
What features do you think are causing the issue
- [x] Reader
Does an issue affect all spreadsheet file formats? If not, which formats are affected?
CSV, HTML
Which versions of PhpSpreadsheet and PHP are affected?
5.1.0