Review main Merged

84424[FEATURE] Add file embedding option to asset viewhelpers

André Buchmann CR +2 V +2 Normal +104 −2 updated 09/10/24, 17:20

Commit message

The viewhelpers f:asset.css and f:asset.script are great but
missed an option to render referenced files inline.

A boolean option "inline" is now added to load the file contents
as inline styles or scripts. This is especially useful for
content elements which are used first in a page and need
some custom css to improve the Cumulative Layout Shift (CLS).

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Garvin Hicking +1
    • Simon Praetorius +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Garvin Hicking +1
    • Simon Praetorius +1
    • core-ci +1 CI

Issues 1

Files 7

Review log 4666

Show 2841 earlier messages
  1. André Buchmann uploaded patch set 1 05/27/24, 12:29

  2. core-ci voted on patch set 1 V +1 05/27/24, 12:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58343

  3. Stefan Bürk commented on patch set 1 05/27/24, 12:40

    Features are main only and need a feature ReST file. You can use https://forger.typo3.com/utilities/rst to create one.
  4. André Buchmann uploaded patch set 2 V +1 05/27/24, 13:07

  5. André Buchmann commented on patch set 2 05/27/24, 13:12

    Reply

    Thank you for mentioning this tool ❤️ Added a ReST file. Open for improvents on the text ;-)
  6. core-ci voted on patch set 2 V +1 05/27/24, 13:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58347

  7. Garvin Hicking commented on patch set 2 05/27/24, 16:22

    Nice option to have! Just a doc question, will test this later, too :)

    Feature-99510-AddFileEmbeddingOptionToAssetViewhelpers.rst:16

    What does CLS stand for, could you use the unabbreviated version here too? Also maybe you can insert linewraps at ~80 chars in this doc?
  8. Garvin Hicking commented on patch set 2 05/27/24, 16:24

    ScriptViewHelper.php:144

    Could this be used to inject arbitrary file contents into the head, if I specify a path like ../../../../etc/passwd or so? Or read other files? Maybe for safety restrict to .js/.css files?
  9. André Buchmann uploaded patch set 3 V +1 05/27/24, 21:02

  10. André Buchmann uploaded patch set 4 05/27/24, 21:06

  11. core-ci voted on patch set 3 V -1 05/27/24, 21:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58355

  12. André Buchmann commented on patch set 3 05/27/24, 21:12

    Feature-99510-AddFileEmbeddingOptionToAssetViewhelpers.rst:16 Reply

    Done

    ScriptViewHelper.php:144 Reply

    With GeneralUtility::getFileAbsFileName() only project files can be accessed. Is this enough for path security? Checking for file extension doesn't really make it more secure? Does it? Also I think the file ending for JavaScript files may not .js but .cjs, ...
  13. core-ci voted on patch set 4 V +1 05/27/24, 21:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58356

  14. Mathias Brodala commented on patch set 4 05/28/24, 14:21

    Please resolve this abbrev. ;-)
  15. Mathias Brodala commented on patch set 4 05/28/24, 14:23

    If at all this should be done with separate viewhelpers, see "single-responsibility principle".
  16. André Buchmann updated the commit message in patch set 5 V +1 05/29/24, 07:49

  17. Garvin Hicking commented on patch set 5 05/29/24, 07:50

    ScriptViewHelper.php:144 Reply

    I understand, that would make white-listing these file patterns problematic. We had a (security-relevant) chat with Olly, so I can resolve this :)
  18. core-ci voted on patch set 5 V +1 05/29/24, 07:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58437

  19. André Buchmann commented on patch set 5 05/29/24, 07:57

    Reply

    I think the single-responsibility for those viewhelpers is to provide an easy way in fluid templates to include additional css/js. It already supports inline styles by writing them as child-content. This change is like the "inline" option for typoscript which does basically the same as page.includeCSS.foo.inline = 1 https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/TopLevelObjects/Page/Index.html#confval-page-includecss

    Reply

    Done

    ScriptViewHelper.php:144 Reply

    As discussed with @oliver.hader@typo3.org this is secure enough as the dev editing a fluid template could include malicious scripts etc. anyways in the template and needs to make sure to include the correct files.
  20. André Buchmann uploaded patch set 6 V +1 07/24/24, 14:51

  21. André Buchmann uploaded patch set 7 07/24/24, 14:54

  22. core-ci voted on patch set 7 V +1 07/24/24, 15:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62108

  23. core-ci voted on patch set 6 V -1 07/24/24, 15:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62107

  24. André Buchmann rebased onto patch set 8 V +1 09/06/24, 13:12

  25. core-ci voted on patch set 8 V +1 09/06/24, 13:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64956

  26. Simon Praetorius commented on patch set 8 09/09/24, 21:39

    CssViewHelper.php:107

    Is this line necessary? I would imagine that embed only ends up in `$this->arguments` and not in tag attributes.

    ScriptViewHelper.php:110

    same here
  27. André Buchmann uploaded patch set 9 V +1 09/10/24, 05:25

  28. core-ci voted on patch set 9 V +1 09/10/24, 05:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65176

  29. André Buchmann commented on patch set 9 09/10/24, 05:32

    CssViewHelper.php:107 Reply

    You're totally right. Removed the line

    ScriptViewHelper.php:110 Reply

    Done
  30. Oli Bartsch uploaded patch set 10 V +1 09/10/24, 12:11

  31. Oli Bartsch voted on patch set 10 CR +1 V +1 09/10/24, 12:11

  32. core-ci voted on patch set 10 V -1 09/10/24, 12:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65229

  33. core-ci voted on patch set 10 V +1 09/10/24, 12:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65229

  34. Oli Bartsch uploaded patch set 11 CR +1 V +1 09/10/24, 12:35

  35. core-ci voted on patch set 11 V +1 09/10/24, 12:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65239

  36. Mathias Brodala commented on patch set 12 V +1 09/10/24, 12:45

    Published edit on patch set 11.
  37. Oli Bartsch commented on patch set 12 CR -1 09/10/24, 12:50

    New argument should be named "inline" to be consitent with corresponding TypoScript (see e.g. https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/TopLevelObjects/Page/Index.html#confval-page-includecss)
  38. Oli Bartsch uploaded patch set 13 CR -1 09/10/24, 12:53

  39. core-ci voted on patch set 12 V +1 09/10/24, 12:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65241

  40. Oli Bartsch uploaded patch set 14 09/10/24, 12:54

  41. Oli Bartsch commented on patch set 14 09/10/24, 12:54

    Reply

    Done
  1. Oli Bartsch voted on patch set 14 CR +1 V +1 09/10/24, 12:54

  2. core-ci voted on patch set 13 V +1 09/10/24, 13:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65244

  3. Mathias Brodala commented on patch set 14 09/10/24, 13:02

    Reply

    ... while dropping my RST improvements. Oh well.
  4. core-ci voted on patch set 14 V +1 09/10/24, 13:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65245

  5. Garvin Hicking commented on patch set 15 CR +1 V +1 09/10/24, 13:06

    Published edit on patch set 14.
  6. Garvin Hicking commented on patch set 15 09/10/24, 13:10

    Reply

    Ew sorry, I made a further mess by editing over Olivers version to change some minor things. The "nonce" thing is factually correct, right? Haven't tested this ;)
  7. core-ci voted on patch set 15 V +1 09/10/24, 13:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65248

  8. Oli Bartsch uploaded patch set 16 V +1 09/10/24, 14:38

  9. core-ci voted on patch set 16 V +1 09/10/24, 14:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65264

  10. Oliver Hader commented on patch set 16 09/10/24, 15:07

    Feature-99510-AddFileEmbeddingOptionToAssetViewhelpers.rst:42

    The `nonce` HTML attribute is only applied in case `useNonce=1` is explicitly given for the corresponding view-helper.
  11. Oliver Hader commented on patch set 17 V +1 09/10/24, 15:11

    Published edit on patch set 16.
  12. Oliver Hader commented on patch set 17 09/10/24, 15:11

    Feature-99510-AddFileEmbeddingOptionToAssetViewhelpers.rst:42 Reply

    Done
  13. Oli Bartsch commented on patch set 17 CR +1 V +1 09/10/24, 15:12

    Reply

    Done
  14. core-ci voted on patch set 17 V +1 09/10/24, 15:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65270

  15. André Buchmann commented on patch set 17 CR +1 V +1 09/10/24, 15:24

    Thank you all for improving my patch <3
  16. Garvin Hicking commented on patch set 17 CR +1 V +1 09/10/24, 15:50

    Feature-99510-AddFileEmbeddingOptionToAssetViewhelpers.rst:14

    This one is in constant spelling pain :D (also "extendend" is wrong). Now wanting to reset votes, so decide if this shall be addressed before merging.
  17. Oli Bartsch commented on patch set 18 CR +1 V +1 09/10/24, 15:57

    Published edit on patch set 17.
  18. Oli Bartsch commented on patch set 18 CR +1 V +1 09/10/24, 15:57

    Feature-99510-AddFileEmbeddingOptionToAssetViewhelpers.rst:14 Reply

    Done
  19. core-ci voted on patch set 18 V +1 09/10/24, 16:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65278

  20. Simon Praetorius uploaded patch set 19 CR +1 V +1 09/10/24, 16:26

  21. Simon Praetorius voted on patch set 19 CR +1 V +1 09/10/24, 16:27

  22. core-ci voted on patch set 19 V +1 09/10/24, 16:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65283

  23. Garvin Hicking voted on patch set 19 CR +1 V +1 09/10/24, 16:45

  24. Oli Bartsch voted on patch set 19 CR +2 V +2 09/10/24, 17:20

  25. Oli Bartsch merged patch set 20 09/10/24, 17:20