Xlsx: register x and o namespaces for VML shapes; add test for #4505#4676
Xlsx: register x and o namespaces for VML shapes; add test for #4505#4676oleibman merged 2 commits intoPHPOffice:masterfrom
Conversation
…ice#4505 Fixes SimpleXMLElement::xpath(): Undefined namespace prefix when reading VML comments/shapes by registering x: (Excel) and o: (Office) namespaces alongside v:. Includes: - tests/PhpSpreadsheetTests/Reader/Xlsx/Issue4505Test.php - tests/data/Reader/XLSX/issue.4505.xlsx Refs: PHPOffice#4505
|
Thank you, I will study this over the weekend. Just to put your mind at ease, do not worry about the coverage failure; coveralls has been having a lot of troubles lately. |
|
I am sorry, your test is not adequate. In particular, your file issue.4505.xlsx is corrupt - Excel will not open it without making changes (I am on Excel 365 on Windows 11 if it matters). Please provide a good example of a file where it is usable without changes in Excel, and where loading it in PhpSpreadsheet without your change fails, but loading it with your change succeeds. It is important to find a spreadsheet which meets those criteria because line 1221 of your Reader/Xlsx module: $clientData = $shape->xpath('.//x:ClientData');is covered in 37 different unit tests, and doesn't fail in any of them. This is presumably a line which might have needed your change, but apparently it doesn't. Same for lines 1221, 1257, and 1267. Line 1376 is exercised a lot less, but it is still exercised (3 times), and it uses the And, looking back at the original issue, it seems that this is a case of unexpected namespacing by a 3rd party application generating the failing spreadsheet. I might be able to work with that. In the meantime, I am converting this PR to draft status. |
|
I have uploaded a much better sample file to match the issue symptoms. Removing from draft status. I will probably merge this in the next day or two, but Github has had some problems today, so I want to delay a bit. |
|
Thank you for your contribution, |
Fixes SimpleXMLElement::xpath(): Undefined namespace prefix when reading VML comments/shapes by registering x: (Excel) and o: (Office) namespaces alongside v:.
Includes:
Refs: #4505