70798[FEATURE] Provide SvgInline viewhelper
Commit message
Review
-
Code review CR 0
-
Verified V 0
Issues 1
Files 6
- typo3/sysext/core/Documentation/Changelog/12.0/Feature-93550-SvgInlineViewHelper.rst1new+41 −0
- typo3/sysext/extbase/Classes/Service/SvgService.php2new+63 −0
- typo3/sysext/extbase/Tests/Fixture/SvgServiceTestExpected.svgnew+3 −0
- typo3/sysext/extbase/Tests/Fixture/SvgServiceTestOriginal.svgnew+3 −0
- typo3/sysext/extbase/Tests/Unit/Service/SvgServiceTest.php1new+56 −0
- typo3/sysext/fluid/Classes/ViewHelpers/SvgInlineViewHelper.php17new+79 −0
Review log 3949
Show 1924 earlier messages
-
Marcus Schwemer uploaded patch set 1 08/27/21, 12:42
-
Marcus Schwemer commented on patch set 1 08/27/21, 12:47
-
core-ci voted on patch set 1 V -1 08/27/21, 13:07 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15724
-
Henrik Elsner commented on patch set 1 08/27/21, 13:08
Nice feature! Without further checking: what would you say about adding that feature as a attribute into the image viewhelper already existing (either as addition or replacement) something like "embedSvg" could be set via bool and do the same magic as your current vh does - just within image. The ImageVh can then be use everywhere and in case a SVG is used it gets embedded (if configured that way) Just an impulse -
Marcus Schwemer uploaded patch set 2 08/27/21, 13:10
-
Simon Gilli commented on patch set 2 08/27/21, 13:15
SvgInlineViewHelper.php:32Why not making the argument optional like done here https://github.com/benjaminkott/bootstrap_package/blob/master/Classes/ViewHelpers/InlineSvgViewHelper.php#L40?SvgInlineViewHelper.php:33Same as above.SvgInlineViewHelper.php:34Same as above. -
core-ci voted on patch set 2 V -1 08/27/21, 13:30 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15725
-
Marcus Schwemer commented on patch set 2 08/27/21, 14:32
SvgInlineViewHelper.php:32ReplyThanks for your input. This is the reason, why I removed the argument. "false" is the default, so there is no difference between not setting it and setting it to false. All other arguments (also in Bennies VH) are optional. -
Marcus Schwemer commented on patch set 2 08/27/21, 14:44
Reply
I did not think about until now. Checked the image vh. There are many more attributes, which are used for processing of the image like cropping or attributes, which are not available for svgs like "maxHeight", " maxWidth", et al. IMHO this would add too much complexity and teaching for integrators, to know what attribute is considered for which image. -
Marcus Schwemer commented on patch set 2 CR -1 08/27/21, 14:49
At my company the discussion arised, which attributes should / must be supported. * id * style * data-attributes (BTW: I don't find them in the attribute reference https://developer.mozilla.org/de/docs/Web/SVG/Attribute What else do you consider as necessary? -
Simon Gilli commented on patch set 2 08/27/21, 15:24
SvgInlineViewHelper.php:32ReplyAh I guess phpstan wants optional arguments to be set explicity. Not sure if that check is also included in the core. -
Simon Schaufelberger commented on patch set 2 08/27/21, 15:45
SvgUtility.php:103can be dropped as there is no additional information -
Simon Schaufelberger wrote 08/27/21, 15:46
Removed reviewer Simon Schaufelberger. -
Benjamin Franzke commented on patch set 2 CR -1 08/28/21, 05:43
SvgUtility.php:36Please don't add (new) static utilities that then depend on non-static services. This utility is then a service as well and shouldn't be static then and rather inject ImageService. Oh, and while at it: ImageService (from Extbase) isn't a nice dependency for a EXT:core service. maybe better add this to ext:extbase then.. -
Marcus Schwemer commented on patch set 2 08/30/21, 07:20
SvgUtility.php:36ReplyACK. I had a look at the ImageViewhelper. It looks quite similar as the SvgUtility. What do you think about putting the utility code directly into the viewhelper? -
Marcus Schwemer uploaded patch set 3 08/30/21, 15:35
-
core-ci voted on patch set 3 V +1 08/30/21, 15:51 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15879
-
Helmut Hummel commented on patch set 3 08/30/21, 16:04
I think most of my question arise due to unawareness of potential usecases. To me inline SVGs are useful for SVGs placed in very special places on a page and for special (small) SVGs like icons or logos. Allowing editor provided SVGs (aka FAL resources) seems odd to me. Can you elaborate on a few use cases where you'd find such VH useful?SvgInlineViewHelper.php:59Historically, the image Service handles both string paths and FAL resources. This mainly was done for backwards compatibility. Rather than introducing yet another view helper that needs to be deprecated later on, I suggest to build one which covers the exact use case and accepts strictly validated arguments for it.SvgInlineViewHelper.php:65This must be removed here in any case. Proper SVG sanitisation is done on FAL file upload and shouldn't be done for SVG files from extension resources.SvgInlineViewHelper.php:80Can you elaborate on the use case for manipulating the SVG before inlining the HTML? In general, doing so seems to be more of a processing step, that should be performed elsewhere, not in the VH itself. -
Marcus Schwemer commented on patch set 3 08/31/21, 08:03
Reply
Good question. Indeed, in an internal version I do not use FAL resources. Then I came across the VH in the bootstrap package, where both options are provided. This was the reason, why I did that too. Furthermore, it would be "in line" with the image VH, which also provides both possibilities. And yes, I agree to remove the image option.SvgInlineViewHelper.php:59ReplyAckSvgInlineViewHelper.php:65ReplyAckSvgInlineViewHelper.php:80ReplyWhat do you mean with "performed elsewhere"? In a service for example? In the first patchset I used a utility and moved the functionality inline. I thought about a service too, but I did not see an advantage of an extra service, because these few lines will (probably) not be reused at any other place. I had also a look at the image vh, where the attributes are also manipulated in the vh. If I shall move it to another place, what would be the appropriate location? EXT:fluid/Classes/Service/SvgTagService.php or elsewhere? -
Marcus Schwemer uploaded patch set 4 08/31/21, 10:46
-
core-ci voted on patch set 4 V +1 08/31/21, 11:02 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15922
-
Marcus Schwemer voted on patch set 4 CR -1 08/31/21, 12:07
-
Marcus Schwemer uploaded patch set 5 08/31/21, 13:56
-
core-ci voted on patch set 5 V -1 08/31/21, 14:12 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15938
-
Helmut Hummel commented on patch set 4 08/31/21, 15:26
Reply
> Furthermore, it would be "in line" with the image VH, which also provides both possibilities This is exactly my point. The image VH should NOT handle non FAL resources. It's just that nobody ever got around deprecating the the src attribute. And therefore I would not like to introduce more code, that supports legagcySvgInlineViewHelper.php:80Reply> What do you mean with "performed elsewhere"? It is rather a question regarding the use case. If the main use case is to provide SVGs from extension resources, what is the use case to not provide the ones with already correct width and height, but process them before inlining? -
Marcus Schwemer uploaded patch set 6 09/01/21, 12:10
-
Marcus Schwemer commented on patch set 6 09/01/21, 12:16
SvgInlineViewHelper.php:80Reply UnresolvedThe use case is, if you provide a sitepackage which needs a svg file in various sizes and colors, it can be inlined via the vh applying the modifications. Otherwise it would be necessary to provide a special svg for each use case. Same applies to the id, which might be different in each usage. -
core-ci voted on patch set 6 V +1 09/01/21, 12:29 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16008
-
Sybille Peters commented on patch set 6 09/13/21, 15:15
I am wondering what are the security implications. Since unfortunately SVG is on the (growing) list of other possibly untrustworthy sources * https://security.stackexchange.com/questions/26264/what-does-a-html-filter-need-to-do-to-protect-against-svg-attacks * https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/9.5.x/Important-94492-IntroduceSVGSanitizer.html There is an upgrade wizard to sanitize existing SVG files - but we can't really be sure everyone has executed this. Also if the file is not uploaded via FAL, it might not be sanitized anyway. While this problably applies to SVGs anyway, no matter whether inline or not - it may be something to consider if the VH should do a check or not. Apart from security (and email client support) - I thought inline SVG might be a good idea to use for the Fluid emails. If you use the SystemEmail layout it will for example pass an image using backend.loginLogo from global configuration. In this case it would have been nice to pass it along as inline SVG because either you are out of luck if you did not provide the absolute URL of the image in backend.loginLogo and it can't be loaded or if you did, the receiver of the email has to enable the loading of the (external) image. I assume there are other use cases where the image from the configuration is to be used or some user supplied images but the image should be passed as inline SVG in an email. However, unless sure they are sanitized - might want to be careful there. I have not read up yet on potential problems of SVG in HTML in E-Mail, but if in doubt if something can be a potential security problem - the answer is usually yes ... :( -
Benni Mack wrote 11/29/21, 10:09
Change destination moved from master to main -
Benni Mack updated the commit message in patch set 7 11/29/21, 13:27
-
core-ci voted on patch set 7 V +1 11/29/21, 14:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20031
-
Benni Mack commented on patch set 7 01/06/22, 12:13
Reading through this change, the only "new" thing would be the "viewBox" option, right?SvgService.php:9any reason why this needs to be a Singleton class? -
Marcus Schwemer uploaded patch set 8 02/05/22, 09:12
-
core-ci voted on patch set 8 V -1 02/05/22, 09:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23044
-
Marcus Schwemer uploaded patch set 9 02/05/22, 09:36
-
core-ci voted on patch set 9 V -1 02/05/22, 09:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23048
-
Marcus Schwemer commented on patch set 9 02/05/22, 09:39
SvgUtility.php:36ReplyDoneSvgUtility.php:103ReplyDoneSvgService.php:9ReplyDoneSvgInlineViewHelper.php:32ReplyDone -
Marcus Schwemer uploaded patch set 10 02/05/22, 09:40
-
Marcus Schwemer commented on patch set 10 02/05/22, 09:43
Reply
Yes.Removed / replaced all code, which is deprected in php8 or php8.1 -
Marcus Schwemer commented on patch set 10 02/05/22, 09:48
Reply
DoneSvgInlineViewHelper.php:33ReplyDoneSvgInlineViewHelper.php:34ReplyDone -
core-ci voted on patch set 10 V +1 02/05/22, 09:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23049
-
Guido Schmechel commented on patch set 10 02/20/22, 14:24
Feature-93550-SvgInlineViewHelper.rst:34UnresolvedI had to adjust the path in v12 in my review: EXT:backend/Resources/Public/Images/typo3_logo_orange.svgSvgServiceTest.php:56UnresolvedI am missing here the test cases in case of error, i.e. checking the file extension, if e.g. no SVG was passed.SvgInlineViewHelper.php:12UnresolvedIn the other Core ViewHelpers, the usage was added as a comment in the class. Can we do the same here? -
Volker Kemeter commented on patch set 10 12/22/22, 13:45
Reply
may i give you an answer to your question @helmut? we do have a couple of projects, where the clients are able to upload svg images (logos, icons and so on) - but we take care about the color of these images. and this is only possible, if we replace, for example, die fill attribute with "currentColor", because the client is not aware or able to change it properly. the other thing is, that we might inline css styles into the svg image (with, for example css variables) to animate stuff properly with settings from a content element or page properties. and last but not least, we add nodes to the svg with text from a content element or page properties - to then, afterwards, animate them. but for me/us one of the most importants things is, to inline svgs only, if they are accessible - and most of the editor svgs arend accessible - and therefor we update/add nodes or change stuff in the inline svg. long story short: (our) editors dont care about things like that in svgs and upload them in a content element - and that might break design or even worse, the a11y of a website. -
Sybille Peters wrote 12/25/22, 10:27
Removed cc Sybille Peters. -
Benni Mack commented on patch set 10 09/21/23, 16:55
Marcus, thanks for this patch. Finally I get around to it (and late to the party). I do not understand a few things in this patch: * AFAICS nothing in this has something to do with Extbase - wrong namespace, wrong extension * I personally dislike "...Service" classes, so I was actually looking to understand what the "SvgService" does. I do not understand it by reading. So something with "here is an SVG content, and we wrap it in another SVG?" I am sure we have had some discussions around this in the past but I failed to go through all the code here yet. As we're currently working on a solution to process SVGs (https://review.typo3.org/c/Packages/TYPO3.CMS/+/80617) the whole topics does not seem easy ;) and we need to test it in the wild. I actually wonder if we should have something like an "inline" option in the Image ViewHelper to pump a file as data string (ya know, base64 etc) or actually work with #use syntax of SVG as we might need something like this for icons in the future in general in a more common way. -
Garvin Hicking commented on patch set 10 10/10/23, 10:30
(Added myself to this, I'd be interested into resolving/helping/working on this) -
Garvin Hicking commented on patch set 10 09/04/24, 14:51
Is this maybe obsoleted by https://review.typo3.org/c/Packages/TYPO3.CMS/+/80097 to achieve a similar thing, but with base64 encoding? -
Marcus Schwemer abandoned the change 10/21/24, 06:22
It's obsolete. There are other / better ways to do it.
Unresolved