Review main Merged

68255[BUGFIX] Trim locallang label references in LanguageService

Georg Ringer CR +2 V +2 Normal +109 −5 updated 03/09/21, 15:05

Commit message

LanguageService::sL(), also known as the split label function,
is widely used through Core and third-party extensions. It
checks if the given input is a label reference and otherwise
just returns the input.

Since this method is often used with dynamic values, coming
from e.g. XML files, there might be whitespace in the input
string. In such case the label reference can not be resolved,
even if the key is valid, and the input gets returned unchanged.

To prevent this behaviour, LanguageService::sL() now applies
trim() to the input, whenever a specifc strpos() check takes place.

Review

  • Code review CR +2 Done
    • Richard Haeser +2
    • Markus Klein +1
  • Verified V +2 Done
    • Richard Haeser +2
    • Markus Klein +1
    • TYPO3com +1 CI
    • core-ci +1 CI

Issues 1

Files 2

Review log 1418

  1. Georg Ringer uploaded patch set 1 03/08/21, 19:56

  2. Georg Ringer commented on patch set 1 03/08/21, 19:57

    This change is ready for review.
  3. TYPO3com voted on patch set 1 V +1 03/08/21, 20:03 Completed build in 07m 07s on Mon, 8 Mar, 08:03 PM Test Summary: 32638 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9943

  4. core-ci voted on patch set 1 V +1 03/08/21, 20:10 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1288

  5. Richard Haeser voted on patch set 1 V +1 CR +1 03/08/21, 20:15

  6. Guido Schmechel voted on patch set 1 CR +1 03/08/21, 21:09

  7. Oli Bartsch commented on patch set 1 03/08/21, 21:23

    Hi, this would apply to 100+ more places in Core. Should we change them as well? Actually already in this class, there is `$title = htmlspecialchars($languageService->sL($conf['appearance']['newRecordLinkTitle']));` I mean, sure this will solve *this* issue. But is there a real world use-case, writing XML like in the forge issue? To me, this looks more like a bug in the integrators' FlexForm. And as I said, if we change this occurrence, we might have to change all other places as well. Otherwise, tomorrow there will be the next forge issue complaining about another place and maybe even with questions like "why does it work there but not here?".
  8. Richard Haeser commented on patch set 1 V 0 CR 0 03/08/21, 21:26

    Reply

    Good point. Thinking out loud, what if we should trim the input string in the `sL` method?
  9. Georg Ringer commented on patch set 1 03/08/21, 21:35

    Reply

    we fixed that for the labels and yes the issue is because lot of tools do autoformatting and move the string into next line. having a trim in sL would certainly be the best solution - what do you think Olver?
  10. Oli Bartsch commented on patch set 1 03/08/21, 21:46

    Reply Unresolved

    Yes, already though about the same thing. This, however, is not that easy, since sL() often just returns the input string, which should not be trimmed. Therefore, trim() can only be applied to the input, after we ensured, the input string is a label reference. In any way, this needs to be tested very well, since LanguageService is used a lot through the core and in third-party extensions.
  11. Guido Schmechel wrote 03/09/21, 08:42

    Removed Code-Review+1 by Guido Schmechel <guido.schmechel@brandung.de>
  12. Oli Bartsch uploaded patch set 2 03/09/21, 14:07

  13. TYPO3com voted on patch set 2 V +1 03/09/21, 14:12 Completed build in 05m 30s on Tue, 9 Mar, 02:12 PM Test Summary: 32680 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9968

  14. core-ci voted on patch set 2 V +1 03/09/21, 14:18 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1322

  15. Richard Haeser voted on patch set 2 V +1 CR +1 03/09/21, 15:02

  16. Markus Klein voted on patch set 2 V +1 CR +1 03/09/21, 15:02

  17. Richard Haeser voted on patch set 2 V +2 CR +2 03/09/21, 15:05

  18. Richard Haeser merged patch set 3 03/09/21, 15:05