benjaminkott / benjaminkott/bootstrap_package

SvgUtility.php throws PHP warnings when rendering certain SVGs

Open
#1,084 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
355
Forks
212
Avg merge
1h 4m
Merged PRs (30d)
31

Description

Hi,

SvgUtility.php is throwing the following warnings when rendering certain SVGs:

Core: Error handler (FE): PHP Warning: simplexml_load_string(): ^ in /var/www/typo3/packages/extension_name/Classes/Utility/Extern/SvgUtility.php line 59
Core: Error handler (FE): PHP Warning: simplexml_load_string(): <sfw xmlns="&ns_sfw;"> in /var/www/typo3/packages/extension_name/Classes/Utility/Extern/SvgUtility.php line 59
Core: Error handler (FE): PHP Warning: simplexml_load_string(): namespace warning : xmlns: URI &ns_sfw; is not absolute in /var/www/typo3/packages/extension_name/Classes/Utility/Extern/SvgUtility.php line 59

This only happens with SVGs that contain metadata like this:

``

A closed/solved [forge issue](https://forge.typo3.org/issues/86428) already exists but this is coming from your SvgUtility Class. For now we patched [this](https://github.com/benjaminkott/bootstrap_package/blob/ad453360a925ea0dc6c68783bd5d425f002a7c8b/Classes/Utility/SvgUtility.php#L59) line with the solution from the mentioned forge issue:

`$svgElement = simplexml_load_string($svgContent, 'SimpleXMLElement', LIBXML_NOERROR | LIBXML_NOWARNING);`

... and the error is gone. :)

PS: Didn't happen with BP < 12

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in Classes/Utility/SvgUtility.php at line 59, where simplexml_load_string() parses the SVG content. Reproduce the warning with an SVG containing Adobe SaveForWeb metadata such as . Done means those SVGs render without PHP warnings while the existing SVG utility behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.