Review main Merged

71554[BUGFIX] Properly encode JSON when forwarding to RequireJS

Oliver Hader CR +2 V +2 Normal +88 −2 updated 10/21/21, 18:07

Commit message

When forwarding configuration as JSON encoded data when loading
RequireJS modules in form engine, escape sequences need to be
handled explicitly. It is not possible to break the serialization
by injection techniques, however client-side parsing might fail.

The problem has been discovered, when PHP class names
(e.g. `\Vendor\Package\Name`) lead to JSON parsing errors
(e.g. `JSON.parse('"\\Vendor\\Package\\Name"');`).

Review

  • Code review CR +2 Done
    • Oliver Hader +2
    • Stefan Bürk +1
    • Mathias Brodala +1
  • Verified V +2 Done
    • Oliver Hader +2
    • core-ci +1 CI

Issues 1

Files 3

Review log 910

  1. Oliver Hader uploaded patch set 1 10/12/21, 08:25

  2. Mathias Brodala commented on patch set 1 10/12/21, 08:31

    GeneralUtility.php:3547

    I know it's for consistency with the method above but this should at least go into the StringUtility instead IMO. The method above is IMO misplaced here, too.
  3. Oliver Hader commented on patch set 1 10/12/21, 08:34

    GeneralUtility.php:3547 Reply

    I see... however, it would be misplaced in `StringUtility` as well since it handles arbitrary data (array, object, string, int, float, nullables, ...). `SerializationUtility` or `JsonSerializer` or similar would be more appropriate.
  4. core-ci voted on patch set 1 V +1 10/12/21, 08:44 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17950

  5. Mathias Brodala commented on patch set 1 10/21/21, 13:58

    GeneralUtility.php:3547 Reply

    As discussed in Slack we don't have a perfect location for these yet. So for now this should be fine here but in the long term these should be bundled and migrated accordingly.
  6. Mathias Brodala voted on patch set 1 CR +1 10/21/21, 14:02

  7. Stefan Bürk commented on patch set 1 CR +1 10/21/21, 14:58

    Maybe I'm stupid - how can it/I verify it ? Code looks good so far.
  8. Oliver Hader voted on patch set 1 V +2 CR +2 10/21/21, 15:43

  9. Oliver Hader merged patch set 2 10/21/21, 15:44

  10. Oliver Hader commented on patch set 2 10/21/21, 18:07

    Reply