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

Special Characters in Image File Name #2416

Merged
merged 3 commits into from Dec 6, 2021
Merged

Conversation

oleibman
Copy link
Collaborator

@oleibman oleibman commented Nov 27, 2021

Fix #2415. Fix #1470. If path name of image contains anything other than ASCII, or if it contains # or space or probably other exceptions, PhpSpreadsheet creates a file that Excel cannot, for whatever reason, read (it is valid xml). When adding an image to a spreadsheet, Excel does not retain the original path name; PhpSpreadsheet does, but probably shouldn't. It is changed to save the image file in the zip as the MD5 hash of the original path name. This produces a file that Excel can read. In addition, it ensures that, if the image is used in multiple places, it is saved in the Excel file only once. As a consequence of that change ... Fix #2323. Fix #1153. Fix #543.

Because this error becomes evident only when opening the file in Excel, it is difficult to write a test case. I have instead duplicated sample Basic/05... using image files whose names match the reported error conditions.

This is:

- [x] a bugfix
- [ ] a new feature

Checklist:

Why this change is needed?

Fix PHPOffice#2415. Fix PHPOffice#1470. If path name of image contains anything other than ASCII, or if it contains # or space or probably other exceptions, PhpSpreadsheet creates a file that Excel cannot, for whatever reason, read (it is valid xml). When adding an image to a spreadsheet, Excel does not retain the original path name; PhpSpreadsheet does, but probably shouldn't. It is changed to save the image file in the zip as the MD5 hash of the original path name. This produces a file that Excel can read. In addition, it ensures that, if the image is used in multiple places, it is saved in the Excel file only once.

Because this error becomes evident only when opening the file in Excel, it is difficult to write a test case. I have instead duplicated sample Basic/05... using image files whose names match the reported error conditions.
Remove some newly dead code.
@oleibman oleibman merged commit 5174a4a into PHPOffice:master Dec 6, 2021
@oleibman oleibman deleted the issue2415 branch February 6, 2022 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment