Skip to content
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

Invalid HTML due to readEnding failure. #1107

Closed
j-fulbright opened this issue Jul 24, 2019 · 4 comments · Fixed by #4184
Closed

Invalid HTML due to readEnding failure. #1107

j-fulbright opened this issue Jul 24, 2019 · 4 comments · Fixed by #4184

Comments

@j-fulbright
Copy link

This is:

- [X] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

The HTML is valid and is able to find the end which is nothing more than a > symbol

What is the current behavior?

Due to size of the file returned from filesize() the fseek is returning no data which causes it to fail. This appears to be due to using the same filename for loadingIntoExisting. The filesize reported is for the original version, but when it is updated with new data filesize does not report the new size.

What are the steps to reproduce?

Try to use loadIntoExisting() on a smaller HTML file (in this case the OS is reporting 1,518 bytes, 4k on disk). Filesize returns 19792 as the size and then tries to seek to the offset based off of the sample size (19792 - 2048) which goes past the end of the file.

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:

<?php

require __DIR__ . '/vendor/autoload.php';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

// add code that show the issue here...
                $reader = new \PhpOffice\PhpSpreadsheet\Reader\Html;
                $reader->setSheetIndex($index);
                $reader->loadIntoExisting('/tmp/smallhtml'. $spreadsheet);

Which versions of PhpSpreadsheet and PHP are affected?

Php 7.1.29 / PhpSpreadsheet 1.8

@j-fulbright
Copy link
Author

This looks to be due to caching that is used for filesize().

I can fix this on our side by forcing a reset before trying to loadIntoExisting(), but maybe PhpSpreadhseet should be doing that as well.

@PowerKiKi
Copy link
Member

Would you be able to suggest a PR covered with tests ?

@stale
Copy link

stale bot commented Nov 20, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@stale stale bot added the stale label Nov 20, 2019
@stale stale bot closed this as completed Nov 27, 2019
@oleibman
Copy link
Collaborator

Still an issue - reopening.

@oleibman oleibman reopened this Sep 30, 2024
@stale stale bot removed the stale label Sep 30, 2024
oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Oct 6, 2024
Fix PHPOffice#1107. Clear statcache for file before requesting its size.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants