Review main Merged

84182[BUGFIX] Do not pass TypoScript attributes as script/link tag attribute

Garvin Hicking CR +2 V +2 Hard +310 −54 updated 05/13/24, 22:07

Commit message

Attributes passed via TypoScript like:

```
page {
    includeJSLibs {
      someIncludeFile = EXT:sitepackage/...
      someIncludeFile.forceOnTop = 1
    }
```

were wrongly passed on to the `<script>` tag, resulting in:

```
<script src="/_assets/…" forceontop="1"></script>
```

This patch streamlines removing the specific `<script>` and `<link>`
tag attributes with a central function to prevent further copy+paste
differences, and better makes visible which TypoScript attributes
are removable for which type. Tests are added to ensure this works,
and can act as a regression check.

All of the keys that are unset from `additionalAttribute`s are handled
through their `addCssFile/addCssLibrary/addJsFile/addJsFooterLibrary()`
methods, and thus would not be emitted again.

Please note, this patch deals with one part of the issue. The other
portion about whether "data." is a good TypoScript subkey or not
is beyond scope, and was already fixed in documentation.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Benni Mack +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Oliver Klee +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 3

Review log 1317

  1. Garvin Hicking uploaded patch set 1 05/08/24, 19:28

  2. Garvin Hicking updated the commit message in patch set 2 05/08/24, 19:29

    Speling
  3. core-ci voted on patch set 1 V -1 05/08/24, 19:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57415

  4. core-ci voted on patch set 2 V -1 05/08/24, 19:37 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57416

  5. Oliver Klee commented on patch set 2 05/08/24, 20:03

    Can we cover this with a regression test (i.e., a test that fails while the bug is present and that passes when the bug is fixed)?
  6. Garvin Hicking uploaded patch set 3 V -1 05/08/24, 20:44

    Bugfix for missing CSS type
  7. Garvin Hicking commented on patch set 3 05/08/24, 20:45

    Reply

    (Was yet waiting for the tests on this to execute :) I'm afraid maybe not from me, this is rather complicated, because the changed logic is that one huge method `processHtmlBasedRenderingSettings` in the `typo3/sysext/frontend/Classes/Http/RequestHandler.php` class. The tests that were shipped with the feature (https://review.typo3.org/c/Packages/TYPO3.CMS/+/65008/21/typo3/sysext/core/Tests/Functional/Page/PageRendererTest.php#393) are when the bug already occured due to what is passed to the addCss/Js-methods. The only other usage of `processHtmlBasedRenderingSettings` so far is a hard-core page meta test in `typo3/sysext/frontend/Tests/Unit/Http/RequestHandlerTest.php` that mocks so many things, I don't know how to access this. So, I would sadly need very detailed instructions on how to get this lifted, as I'm stil a novice phpunit tester. :-)
  8. core-ci voted on patch set 3 V +1 05/08/24, 20:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57418

  9. Garvin Hicking uploaded patch set 4 V +1 05/13/24, 08:55

    Add tests
  10. Garvin Hicking commented on patch set 4 05/13/24, 08:56

    Reply

    @typo3-coding@oliverklee.de - I found another approach with a Frontend request that checks on the generated links. I added some varations for each CSS/JS placement with a few custom attributes. The test fails without this applied patch and is green with the patch. Please tell me if you think this could be sufficient - thanks for pushing for this, this helped me. :-)
  11. core-ci voted on patch set 4 V +1 05/13/24, 09:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57585

  12. Oliver Klee commented on patch set 4 V +1 05/13/24, 09:12

    Reply

    > The test fails without this applied patch and is green with the patch. Awesome! Yes, that's exactly the kind of code behavior I was thinking of. > thanks for pushing for this, this helped me. <3
  13. Benni Mack voted on patch set 4 CR +1 V +1 05/13/24, 20:11

  14. Stefan Bürk voted on patch set 4 CR +2 V +2 05/13/24, 20:22

  15. Stefan Bürk voted on patch set 4 CR +1 V +1 05/13/24, 20:27

  16. Stefan Bürk voted on patch set 4 CR +2 V +2 05/13/24, 22:07

  17. Stefan Bürk merged patch set 5 05/13/24, 22:07