Review main Merged

86543[BUGFIX] Prevent undefined array key access in 'removeTags' parsing

Garvin Hicking CR +2 V +2 Normal +116 −15 updated 10/11/24, 07:09

Commit message

This patch addresses a regression introduced in the TypoScript
config parsing of the 'removeTags' processing. When 'removeTags'
was set as a string (not an array), a PHP "Undefined array
key access" warning occurred.

Tests are added to parse TSconfig variant for strings and
arrays, in addition to the existing YAML-based tests.

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Benjamin Franzke +1
    • Georg Tiefenbrunn +1
    • Oli Bartsch +1
    • Oliver Hader +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Benjamin Franzke +1
    • Georg Tiefenbrunn +1
    • Oli Bartsch +1
    • core-ci +1 CI

Issues 2

Files 4

Review log 1925

  1. Garvin Hicking uploaded patch set 1 10/10/24, 06:15

  2. Garvin Hicking updated the commit message in patch set 2 10/10/24, 06:16

  3. core-ci voted on patch set 1 V +1 10/10/24, 06:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67475

  4. core-ci voted on patch set 2 V +1 10/10/24, 06:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67476

  5. Oli Bartsch voted on patch set 2 CR +1 V +1 10/10/24, 06:29

  6. Benjamin Franzke commented on patch set 2 10/10/24, 07:09

    HtmlParser.php:957

    Without having this tested, just from inspecting the code: This line still looks fishy: That means `removeTags.` can only be used if `removeTags` is used as well. Expression in code: ``` removeTags { … } ``` would be ignored when there is no ``` removeTags = … ``` assignment. Seems that's an issue since https://review.typo3.org/c/Packages/TYPO3.CMS/+/86047
  7. Garvin Hicking uploaded patch set 3 CR +1 V +1 10/10/24, 07:13

  8. Garvin Hicking commented on patch set 3 10/10/24, 07:16

    HtmlParser.php:957 Reply

    I've just added tests for parsing the TSconfig notation, in which the application seems to work with a TS array assignment. Could you help me figure this out how I would need to adapt the test for the case you describe?
  9. core-ci voted on patch set 3 V -1 10/10/24, 07:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67478

  10. Garvin Hicking uploaded patch set 4 V -1 10/10/24, 07:28

    CGL
  11. core-ci voted on patch set 4 V +1 10/10/24, 07:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67480

  12. Benjamin Franzke commented on patch set 3 10/10/24, 07:44

    HtmlParser.php:957 Reply

    Had to track this down myself as well. `removeTags` gets value `1` assigned by `TYPO3\CMS\Core\Configuration\Richttext::convertPlainArrayToTypoScriptArray` when transforming RTE yaml config into a TSconfig-like array. That means: `removeTags=1` is not assigned when the default rte_ckeditor `typo3/sysext/rte_ckeditor/Configuration/RTE/Processing.yaml` config is not used, otherwise – although being overwritten – `removeTags=1` is written due to the yaml configuration.
  13. Garvin Hicking commented on patch set 4 10/10/24, 07:52

    HtmlParser.php:957 Reply

    So if I understand correctly, we would need to change ``` if (!empty($TSconfig['removeTags'])) { ``` to ``` if (!empty($TSconfig['removeTags']) || !empty($TSconfig['removeTags.'])) { ``` right?
  14. Garvin Hicking uploaded patch set 5 V +1 10/10/24, 14:13

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

  16. Garvin Hicking uploaded patch set 6 V +1 10/10/24, 14:20

    Additional test
  17. Garvin Hicking commented on patch set 5 10/10/24, 14:21

    @ben@bnf.dev I have refactored this due to the findings that we must not test inline-tag removal at block-level, because RteHtmlParser->TS_transform_db() is the one doing that, not the methods we're testing with 'removeTags'. Before, my patch just worked thanks to that, and not the "real removeTags" logic. I've now added both block-level and inline-level testing, so that the removeTags logic actually is utilized. I also included your variant of the changed $removeTagsArray logic, which is way more readable. Thank you. I am unsure whether we need to include your extension fixture approach to disable htmlSanitize to verify untampered data. Please advise, if you want that, I can include it here.
  18. Garvin Hicking commented on patch set 6 10/10/24, 14:21

    HtmlParser.php:957 Reply

    (Changed logic to WIP variant from Benjamin, thanks)
  19. core-ci voted on patch set 6 V +1 10/10/24, 14:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67514

  20. Benjamin Franzke commented on patch set 6 CR +1 V +1 10/10/24, 14:37

    Reply

    Thanks, this is good to go.
  21. Oliver Hader voted on patch set 6 CR +1 10/10/24, 17:34

  22. Georg Tiefenbrunn commented on patch set 6 CR +1 V +1 10/11/24, 06:25

    Thank you for the quick fix!
  23. Oli Bartsch voted on patch set 6 CR +1 V +1 10/11/24, 06:52

  24. Garvin Hicking voted on patch set 6 CR +2 V +2 10/11/24, 07:09

  25. Garvin Hicking merged patch set 7 10/11/24, 07:09