Review main Merged

84785[BUGFIX] Fix backend page tree filter with special characters

Andreas Kienast CR +2 V +2 Easy +3 −2 updated 06/21/24, 09:27

Commit message

When filtering the page tree with characters that have
special meaning for a regular expression (for example,
")" or "(" or "?" and some others), the filtering would
return a "Page Tree error".

JavaScript does not have something like "preg_quote",
so this uses the escape string provided by the MDN
with fixed special characters.

Review

  • Code review CR +2 Done
    • Andreas Kienast +2
    • Jasmina Ließmann +1
    • Benni Mack +1
  • Verified V +2 Done
    • Andreas Kienast +2
    • Jasmina Ließmann +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 1114

  1. Andreas Kienast uploaded patch set 1 06/19/24, 12:47

  2. Andreas Kienast updated the commit message in patch set 2 06/19/24, 12:47

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

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

  5. Jasmina Ließmann voted on patch set 2 CR +1 V +1 06/19/24, 19:51

  6. Simon Schaufelberger commented on patch set 2 06/20/24, 21:45

    tree.ts:1041

    Could you add a comment maybe what is happening here to make it clear as this regex is not trivial.
  7. Garvin Hicking commented on patch set 2 06/21/24, 05:04

    tree.ts:1041 Reply

    This regular expression /[/\-\\^$*+?.()|[\]{}]/g is designed to match any character that has a special meaning in regular expressions (often referred to as "metacharacters"). Here's a breakdown of the regex: /.../g: The pattern is enclosed between slashes, and the g at the end signifies the global flag, which means the regex will match all occurrences in the input string, not just the first one. [...]: This denotes a character class, which matches any one of the characters inside the square brackets. Inside the character class: / (forward slash) is included. - (dash) is included. \\ (backslash) is included, but it is escaped by another backslash, so it matches a single backslash character. ^ (caret) is included. $ (dollar sign) is included. * (asterisk) is included. + (plus sign) is included. ? (question mark) is included. . (dot) is included. ( (left parenthesis) is included. ) (right parenthesis) is included. | (pipe) is included. [ (left square bracket) is included, but it needs to be escaped with a backslash within a character class. ] (right square bracket) is included. { (left curly brace) is included. } (right curly brace) is included. Thus, the regex matches any of the following characters: /, -, \, ^, $, *, +, ., ?, (, ), |, [, ], {, and }. These are all characters that have special meanings in regular expressions, and this regex is designed to find and match any of them in a given string. IMO that doesn't need a specific code comment at this place, but I can add that later.
  8. Garvin Hicking uploaded patch set 3 CR +1 V +1 06/21/24, 06:26

    document regexp
  9. Garvin Hicking commented on patch set 3 06/21/24, 06:29

    tree.ts:1041 Reply

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

  11. Jasmina Ließmann voted on patch set 3 CR +1 V +1 06/21/24, 08:07

  12. Benni Mack voted on patch set 3 CR +1 V +1 06/21/24, 09:10

  13. Andreas Kienast voted on patch set 3 CR +2 V +2 06/21/24, 09:27

  14. Andreas Kienast merged patch set 4 06/21/24, 09:27