Review main Merged

71032[BUGFIX] Pad multibyte strings correctly

Sybille Peters CR +2 V +2 Normal +141 −2 updated 12/10/24, 17:11

Commit message

A new function StringUtility::multibyteStringPad() is
introduced to handle multibyte strings instead of
str_pad() which will not pad strings with multibyte
characters correctly.

The new function is now used for:

- Fluid ViewHelper format.padding
- TypoScript stdWrap.strPad

Review

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

Issues 2

Files 5

Review log 1520

  1. Sybille Peters uploaded patch set 1 09/11/21, 16:02

  2. Sybille Peters uploaded patch set 2 09/11/21, 16:12

  3. core-ci voted on patch set 1 V +1 09/11/21, 16:16 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16571

  4. core-ci voted on patch set 2 V +1 09/11/21, 16:27 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16573

  5. Sybille Peters uploaded patch set 3 09/11/21, 16:54

  6. core-ci voted on patch set 3 V +1 09/11/21, 17:10 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16576

  7. Sybille Peters uploaded patch set 4 09/11/21, 17:53

  8. Sybille Peters uploaded patch set 5 09/11/21, 17:59

  9. core-ci voted on patch set 4 V +1 09/11/21, 18:08 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16580

  10. core-ci voted on patch set 5 V +1 09/11/21, 18:17 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16581

  11. Georg Ringer commented on patch set 5 09/11/21, 20:50

    If you didn't come up with this yourself but took it from somewhere else, please add the author
  12. Sybille Peters commented on patch set 5 09/12/21, 13:23

    Reply

    I wrote it myself. The solutions I looked at took a slightly different approach. These are some solutions: - original str_pad (in C): https://github.com/php/php-src/blob/master/ext/standard/string.c - php.net comments, e.g. https://www.php.net/manual/en/function.str-pad.php#116244 - stackoverflow: https://stackoverflow.com/a/14773638/2444812
  13. Sybille Peters commented on patch set 5 09/12/21, 13:33

    Reply

    I could say "inspired by" the solution on Stack Overflow which kind of gave me the idea that PHP does not come with a multibyte solution for str_pad() and you have to write one yourself. But the implementation is quite different (and the comments suggest the solution on Stack Overflow might not work correctly).
  14. Benni Mack voted on patch set 5 V +1 CR +1 09/17/21, 09:08

  15. Wouter Wolters voted on patch set 5 V +1 CR +1 09/22/21, 17:27

  16. Georg Ringer voted on patch set 5 V +2 CR +2 09/22/21, 17:42

  17. Georg Ringer merged patch set 6 09/22/21, 17:42

  18. Simon Schaufelberger commented on patch set 6 09/22/21, 19:14

    can/will this be backported to v10 as well?
  19. Simon Schaufelberger commented on patch set 6 09/23/21, 13:11

    Reply

    this would probably fix my padding issue in my plain text emails 🎉
  20. Simon Schaufelberger commented on patch set 6 12/10/24, 17:11

    Reply

    Done