Review main Merged

70457[FEATURE] Introduce explicit f:sanitize.html view-helper

Oliver Hader CR +2 V +2 Normal +247 −1 updated 08/13/21, 19:58

Commit message

New `<f:sanitize.html build="default">` view-helper is introduced
which directly invokes processing of `typo3/html-sanitize` package. An
optional view-helper argument `build` allows using a defined preset,
or a fully qualified class name of a builder instance as alternative,
which has to implement `\TYPO3\HtmlSanitizer\Builder\BuilderInterface`.

In contrast to `<f:format.html>`, this does NOT invoke `lib.parseFunc`,
and does NOT rely on TypoScript configuration being loaded and parsed.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Wouter Wolters +1
  • Verified V +2 Done
    • Benni Mack +2
    • core-ci +1 CI

Issues 1

Files 4

Review log 2336

Show 811 earlier messages
  1. Oliver Hader uploaded patch set 1 08/11/21, 20:34

  2. Oliver Hader updated the commit message in patch set 2 08/11/21, 20:39

  3. core-ci voted on patch set 1 V -1 08/11/21, 20:48 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14639

  4. Oliver Hader updated the commit message in patch set 3 08/11/21, 20:49

  5. core-ci voted on patch set 2 V -1 08/11/21, 20:50 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14640

  6. Oliver Hader commented on patch set 3 08/11/21, 20:58

    Just got feedback via Slack, it should probably named `f:format.sanitizeHtml`...
  7. core-ci voted on patch set 3 V -1 08/11/21, 21:07 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14641

  8. Oliver Hader commented on patch set 3 CR -1 08/12/21, 13:53

    on it
  9. Benni Mack commented on patch set 3 08/12/21, 13:56

    Reply

    sorry, I'm on it too!
  10. Oliver Hader uploaded patch set 4 08/12/21, 14:05

  11. Claus Due commented on patch set 4 08/12/21, 14:35

    HtmlSanitizeViewHelper.php:96

    $conf is undefined, did you mean to use $arguments?

    HtmlSanitizeViewHelper.php:102

    This line is probably redundant since $build is already passed as argument and is always a string.
  1. core-ci voted on patch set 4 V +1 08/12/21, 14:36 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14750

  2. Benni Mack uploaded patch set 5 08/12/21, 15:15

  3. core-ci voted on patch set 5 V -1 08/12/21, 15:38 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14778

  4. Oliver Hader commented on patch set 5 08/12/21, 15:41

    HtmlSanitizeViewHelper.php:96 Reply

    Ack

    HtmlSanitizeViewHelper.php:102 Reply

    Ack
  5. core-ci commented on patch set 5 08/12/21, 15:45 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14778

  6. Oliver Hader rebased onto patch set 6 08/12/21, 15:50

  7. core-ci voted on patch set 6 V -1 08/12/21, 16:15 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14795

  8. core-ci commented on patch set 6 08/12/21, 16:28 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14795

  9. Oliver Hader rebased onto patch set 7 08/12/21, 20:58

  10. core-ci voted on patch set 7 V +1 08/12/21, 21:21 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14857

  11. Mathias Brodala commented on patch set 7 08/13/21, 06:48

    I'd vote for renaming it to `f:sanitize.html`. The current name sounds like works like `f:format.html` + sanitation.
  12. Benni Mack commented on patch set 8 08/13/21, 07:14

    Published edit on patch set 7.
  13. core-ci voted on patch set 8 V -1 08/13/21, 07:32 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14885

  14. Claus Due commented on patch set 8 08/13/21, 07:58

    I'm wondering if this patch and https://review.typo3.org/c/Packages/TYPO3.CMS/+/70404 are kind of doing the same thing, in which case it could make sense to adjust the other patch to allow `f:format.html` to define the sanitizer it wants to use - instead of adding this new ViewHelper. Currently the other patch implies a usage of `f:format.html` like: <f:format.html htmlSanitize="1">{html}</f:format.html> But we could instead make it accept the same type of `build` (named sanitizer) argument that this patch provides: <f:format.html sanitizer="default">{html}</f:format.html> In essence, argument `sanitizer` on `f:format.html` would work like the `build` argument on this proposed `f:format.htmlSanitize` ViewHelper. If you then pass the `sanitizer` argument when using `f:format.html` it could take priority over the `parseFunc` behavior. We could then also replace the current FE simulation behavior of `f:format.html` with this new Sanitizer implementation, so that if a BE request is detected then `parseFunc` wouldn't trigger at all - instead it would go directly through the Sanitizer (either the one you passed as `sanitizer` argument, or a fallback e.g. `default`).
  15. Oliver Hader commented on patch set 8 08/13/21, 08:04

    Reply

    The look similar, but actually are different (see description and RST file). The main difference is, that `<f:format.html>` ALWAYS calls `ContentObjectRenderer::parseFunc` - which does NOT happen with this change for new `<f:format.htmlSanitize>`.
  16. Oliver Hader commented on patch set 8 08/13/21, 08:05

    Reply

    I like the idea, thx
  17. core-ci commented on patch set 8 08/13/21, 08:07 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14885

  18. Oliver Hader uploaded patch set 9 08/13/21, 09:05

  19. Oliver Hader updated the commit message in patch set 10 08/13/21, 09:05

  20. core-ci voted on patch set 9 V +1 08/13/21, 09:24 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14901

  21. core-ci voted on patch set 10 V +1 08/13/21, 09:33 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14903

  22. Benni Mack voted on patch set 10 V +1 CR +1 08/13/21, 14:31

  23. Wouter Wolters voted on patch set 10 CR +1 08/13/21, 15:34

  24. Benni Mack voted on patch set 10 V +2 CR +2 08/13/21, 19:58

  25. Benni Mack merged patch set 11 08/13/21, 19:58