Bug #92449
closedsvg without defined width or height crash with exception
80%
Description
In version 10.4.9 was changed how TYPO3 handles SVG files, in this version when SVG file does not contain defined width and/or height, therefore can not determine dimensions of file, because of that, when svg file (without defined width) is already in TYPO3 instance (uploaded before update to 10.4.9), it crashes on ImageDimension class with unhandled exception.
Fresh svg file without dimensions can not be uploaded in filelist module.
Files
Updated by Tymoteusz Motylewski about 4 years ago
- Related to Bug #92014: Move SVG image processing into an own file processor added
Updated by Gerrit Code Review about 4 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/65963
Updated by Helmut Hummel about 4 years ago
- Status changed from Under Review to Needs Feedback
I added a workaround, but I'm really interested in how SVGs without defined width or viewport are expected to be handled by TYPO3.
Before 10.4.9 width and height properties of images were set to 0 and files were processed all the time, as processing could never complete.
So yes, no exceptions were thrown, but I'd be interested in the use case for such (from my pov) broken state.
Updated by Helmut Hummel about 4 years ago
- Category changed from Image Cropping to Image Generation / GIFBUILDER
Updated by Jörn Wagner about 4 years ago
Having the same problem. We are using an SVG image map with no dimensions on the outer SVG tag set.
However, I've found a workaround: If you comment out the exception, an entry in sys_file_processedfile
will be generated (albeit with width = 0 AND height = 0
, but that's no problem further on) and the exception will not be thrown again. You could also manually create the database row for that image, as it was not present before with v10.4.8.
SVG source code:
<svg xmlns="http://www.w3.org/2000/svg">
<symbol viewBox="0 0 21.498 21.475" id="svg-icon-button-close">
<path style="fill:#FFFFFF" d="..."/>
</symbol>
<symbol viewBox="0 0 20 20" id="svg-icon-menu">
...
</symbol>
</svg>
Usage in a Fluid template:
<svg role="img" aria-label="Symbolgrafik Menü">
<use xlink:href="{f:uri.image(src: 'EXT:my_ext/Resources/Public/Images/map.svg')}#svg-icon-menu"></use>
</svg>
So here the ImageViewHelper is basically only used to infer the correct path from the extension. Probably not a good idea.
Updated by Gerrit Code Review about 4 years ago
- Status changed from Needs Feedback to Under Review
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/65963
Updated by Helmut Hummel about 4 years ago
Jörn Wagner wrote:
Usage in a Fluid template:
<svg role="img" aria-label="Symbolgrafik Menü">
<use xlink:href="{f:uri.image(src: 'EXT:my_ext/Resources/Public/Images/map.svg')}#svg-icon-menu"></use>
</svg>So here the ImageViewHelper is basically only used to infer the correct path from the extension. Probably not a good idea.
And this exaclty is a use case we should not support imho, but hard throw an exception. Instead of the image view helper, the resource view helper should be used instead:
<use xlink:href="{f:uri.resource(extensionName: 'MyExt', path: 'Images/map.svg')}#svg-icon-menu"></use>
Updated by Jörn Wagner about 4 years ago
Helmut Hummel wrote:
And this exaclty is a use case we should not support imho, but hard throw an exception. Instead of the image view helper, the resource view helper should be used instead:
<use xlink:href="{f:uri.resource(extensionName: 'MyExt', path: 'Images/map.svg')}#svg-icon-menu"></use>
I agree and I've already refactored that usage to use the resource helper. ;-)
However, I'm still getting the exception on another SVG which, curiously enough, has both width and height
and viewbox
set... I'm still analyzing the cause.
Updated by Henri Nathanson about 4 years ago
Problem here, too. EXT:backend extension configuration I moved files from /fileadmin into EXT:my_ext_tpl/Resources .. TYPO3 creates entries in sys_file/sys_file_metadata with storage = 0 and without width/height. Installtool sending testmail breaks with this exception:
throw new \BadMethodCallException('Width and height of the image must be greater than zero', 1597310560);
Updated by jansass no-lastname-given about 4 years ago
Thats really bad because of security fix 10.4.10 rolled out today; which also includes that bug…
Quick workaround: typo3_src-10.4.10/typo3/sysext/core/Classes/Imaging/ImageDimension.php comment out line #76 (no error will be thrown; yet no solution)
Updated by Gerrit Code Review about 4 years ago
Patch set 1 for branch 10.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/66674
Updated by Helmut Hummel about 4 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset b90897db1d13e3078609f1e66c4c91d2df465570.
Updated by Benni Mack almost 4 years ago
- Status changed from Resolved to Closed
Updated by Marcus Förster about 3 years ago
- % Done changed from 100 to 80
not perfect yet; please check+use for "Media Adjustments" [imagewidth]/[imageheight] first
Updated by Marcus Förster about 3 years ago
& may reference to typo3/sysext/core/Classes/Resource/Processing/LocalPreviewHelper.php at
- typo3/sysext/core/Classes/Resource/Processing/SvgImageProcessor.php [48]
- typo3/sysext/core/Classes/Type/File/ImageInfo.php [151]
Updated by Marcus Förster about 3 years ago
the TASK has NAME:CropScaleMask ; but CROP makes no sense with SVGs
@ typo3/sysext/core/Classes/Resource/Processing/SvgImageProcessor.php
Updated by Marcus Förster about 3 years ago
$this->arguments['fileExtension'] is not set to 'svg'
but $file->getProperty('extension') has this information
@ typo3/sysext/fluid/Classes/ViewHelpers/MediaViewHelper.php