Project

General

Profile

Actions

Bug #92449

closed

svg without defined width or height crash with exception

Added by Tomek W about 4 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Image Generation / GIFBUILDER
Target version:
Start date:
2020-09-30
Due date:
% Done:

80%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

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

test-svg-without-dimensions.svg (178 Bytes) test-svg-without-dimensions.svg Tomek W, 2020-09-30 10:53
crash-log.log (6.91 KB) crash-log.log Tomek W, 2020-09-30 11:13
fluid.patch (1.02 KB) fluid.patch Marcus Förster, 2021-10-07 10:37

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #92014: Move SVG image processing into an own file processorClosed2020-08-15

Actions
Actions #1

Updated by Daniel Goerz about 4 years ago

  • Description updated (diff)
Actions #2

Updated by Daniel Goerz about 4 years ago

  • Description updated (diff)
Actions #3

Updated by Tomek W about 4 years ago

Actions #4

Updated by Tymoteusz Motylewski about 4 years ago

  • Related to Bug #92014: Move SVG image processing into an own file processor added
Actions #5

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

Actions #6

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.

Actions #7

Updated by Helmut Hummel about 4 years ago

  • Category changed from Image Cropping to Image Generation / GIFBUILDER
Actions #8

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&quot;>
<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.

Actions #9

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

Actions #10

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>

Actions #11

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.

Actions #12

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);

Actions #13

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)

Actions #14

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

Actions #15

Updated by Helmut Hummel about 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #16

Updated by Benni Mack almost 4 years ago

  • Status changed from Resolved to Closed
Actions #17

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

Actions #18

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]

Actions #19

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

Actions #20

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

Actions #22

Updated by Marcus Förster about 3 years ago

  • File fluid.patch added
Actions #23

Updated by Marcus Förster about 3 years ago

  • File deleted (fluid.patch)
Actions

Also available in: Atom PDF