[php-src] PR #16670: Implement #71517: Implement SVG support for getimagesize() and friends
| From: | nielsdos | Date: | Fri, 01 Nov 2024 14:14:45 +0000 |
| Subject: | [php-src] PR #16670: Implement #71517: Implement SVG support for getimagesize() and friends | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-29465@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/16670
Author: nielsdos
This implements [feature request #71517](https://bugs.php.net/bug.php?id=71517)
[Expose gfxinfo as
php_gfxinfo](https://github.com/php/php-src/commit/3706484c5fa2d52d359a7564c2ebe93dbb199455)
This is necessary for future commits, when we extend the image handling
to support extensions adding their own handlers.
Also extend the struct with fields for when the width and height are not
numbers but strings (e.g. for SVG).
[Add API to register custom image
handlers](https://github.com/php/php-src/commit/3e0d3b3dcb3d852803d5a6dc59c8819f63139ac1)
This is modelled similarly to the password registry API.
We have an array to which new handlers can be added, and when a built-in
handler cannot handle the image, we try the handlers in the array.
The standard module is in control of registering a new constant for the
image file type so that no clashes can occur. It also updates the image
file type count constant. As such, the registration may only happen
during module startup.
[Implement SVG image
handler](https://github.com/php/php-src/commit/3a5fd3ada30cf019743ad2240b1a953c15e07baf)
This implements an SVG handler using the libxml reader API. This does
not parse the entire document but instead uses a pull parser to locate
the root element, check whether it's an svg root, do some extra sanity
checks on the attribute, and fill in the php_gfxinfo structure.