Invalid SVG markup breaks page edit form
Short description of the issue
SVGs with invalid markup will throw an exception in the page edit form when trying to calculate their size.
Expected behavior
Invalid SVGs should gracefully fall back to 0x0px size, like invalid jpeg/png images do.
Actual behavior
An exception is thrown, making it impossible to delete the invalid image from the page.
Optional: Screenshots/Links that demonstrate the issue
This is the page edit form in debug mode. In production mode, it just shows "Server error".
Optional: Suggestion for a possible fix
Check for the result of the simplexml parser when trying to read the width/height in Pageimage.php.
I've created a PR with a suggested fix for this.
Steps to reproduce the issue
- Upload an invalid svg file to an image field
Example content of a file which triggered the problemsh: inkscape: command not found - Save the page
Setup/Environment
- ProcessWire version: latest (3.0.238)
- PHP version: 8.1
:+1: for this. The root issue seems to be a buggy imagick plugin.
This probably only ever happens to SVG without width/height attributes. On the first run, its still valid XML, but getImageInfoSVG doesnt find size attributes, so Imagick is used. Imagick overrides the file contents with sh: inkscape: command not found, which is no longer valid XML and subsequently causes a fatal error.
This happened with PHP 8.0.30 and Imagick 3.7.0, other PHP versions on the same server do not seem to suffer from the same problem.
@daun, can we close this?
@daun, can we close this?
Yeah, I think so :)