-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
PhpOffice\PhpSpreadsheet\Reader\Html::load not working for html files smaller than 2048 bytes. #194
Comments
Do you have HTML files with actual valid data that are smaller than 2048 bytes ? If so what sizes are they ? Would you have any suggestions on how to solve this ? |
It's been a while so bare with me. "Do you have HTML files with actual valid data that are smaller than 2048 bytes ?" The error occurred in the following context: " If so what sizes are they ?" "Would you have any suggestions on how to solve this ?" 99% sure that all validation did was check if the file starts with "<" and ends with ">". How I remember fixing the problem: I ended up extending the provided class. Thank you. |
Hi, I'm using it for 'convert' html files containing table to Xlsx file. I got "Invalid HTML file." exception. I check the html file using some validator, all says valid. At first i didn't suspect it's related to the size, but after debugging it i notice the are static variable TEST_SAMPLE_SIZE on Reader/Html.php `
} not sure why we need to set TEST_SAMPLE_SIZE to 2048, maybe there is certain reason for that. But in my case, since i use read html that is generated by the data, for my latest case it can be as small as 1KB. But maybe this will affect reader performance, i haven't think about performance effect. Regards, |
I have fixed this long time ago in my local fork. |
Thank you @alpha-and-omega for your patch. I was able to complete it with unit tests and merge it. |
This is:
What is the expected behavior?
The bug refers to the PhpOffice\PhpSpreadsheet\Reader\Html::canRead($filename).
To return true if a valid html file(path) is served.
What is the current behavior?
If the filesize is smaller than 2048 the value of the self::TEST_SAMPLE_SIZE the function
will always return false since inside the Html::readEnding() nothing is read by the
fread($this->fileHandle, $blockSize).
I suspect this is caused by the fact that Html::readBegining() is reading after EOF and
fseek($this->fileHandle, $size - $blockSize); does not have the expected behaviour.
Because of this issue I'm unable to load any html file that has a size smaller than 2048.
What are the steps to reproduce?
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
The text was updated successfully, but these errors were encountered: