Review main Merged

91557[BUGFIX] Prevent decoding of user supplied URLs in LinkBrowser

Andreas Nedbal CR +2 V +2 Easy +6 −2 updated 11/13/25, 11:54

Commit message

InputTransformer.toSearchParams for some reason decodes search
parameters after assembling them. This causes properly encoded URLs
to be changed, which violates RFC 1738 section
2.2 "All unsafe characters must always be encoded within a URL." [1]

We create an own URLSearchParams object as a workaround, in order
to avoid this faulty behavior, as this ensures that AjaxRequest
uses the values as-is.

The faulty behavior will be fixed separated for v14 only, see #108052.
This workaround is scoped to the reported issue. A followup patch will
address the decoding inside `AjaxRequest(...).withQueryArguments`,
see #108052.

[1] https://www.rfc-editor.org/rfc/rfc1738#section-2.2

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 2

Files 2

Review log 1014

  1. Andreas Nedbal uploaded patch set 1 11/11/25, 14:50

  2. Andreas Nedbal updated the commit message in patch set 2 11/11/25, 14:51

  3. core-ci voted on patch set 1 V +1 11/11/25, 15:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89017

  4. core-ci voted on patch set 2 V +1 11/11/25, 15:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89018

  5. Andreas Nedbal uploaded patch set 3 V +1 11/11/25, 15:22

  6. core-ci voted on patch set 3 V +1 11/11/25, 15:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89029

  7. Garvin Hicking voted on patch set 3 CR +1 V +1 11/11/25, 20:57

  8. Benjamin Franzke commented on patch set 3 CR -1 11/12/25, 09:19

    Btw, I just noticed that the issue reports about two problems: encoding being decoded and " being escaped. If an non encoded URL is used, like: ``` https://example.org/page?query={"foo":["bar"]} ``` Then it is good that the handler does not automagically applies encoding, but tries to preserve the characters as-is, but it still applies `\` to the `"` symbols, that means the result is not preserved: ``` https://example.org/page?query={\"foo\":[\"bar\"]} ``` I guess that's a link browser issue, but I think worth investigating?

    form-engine-link-browser-adapter.ts:74

    We talked about this yesterday and I think this is a good fix to counter the destructive `decodeURI` in ajax InputTransformer. But, reading https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI again, there's a sentence that makes me doubt: > Compared to encodeURIComponent(), this function encodes fewer characters, preserving those that are part of the URI syntax. > > encodeURI() escapes all characters except: > `A–Z a–z 0–9 - _ . ! ~ * ' ( )` > `; / ? : @ & = + $ , #` > The characters on the second line are characters that may be part of the URI syntax, and are only escaped by encodeURIComponent(). So `encodeURI` is meant for complete URLs and applies some heuristics therefore does not encode values that are part of an url, I mean, InputTransformer uses decodeURI, but is there is chance that characters are altered anyway? In other words, I'm not sure whether `(input: string): string => decodeURI(encodeURI(input))` is 100% idempotent. -1 for now, we need to double check this, or better create an own `URLSearchParams` object, which should be safer.
  9. Benjamin Franzke uploaded patch set 4 CR +1 V +1 11/12/25, 11:02

  10. Benjamin Franzke commented on patch set 4 CR +1 V +1 11/12/25, 11:09

    Reply

    Will be handled separately.

    form-engine-link-browser-adapter.ts:74 Reply

    Done
  11. core-ci voted on patch set 4 V +1 11/12/25, 11:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89265

  12. Garvin Hicking voted on patch set 4 CR +1 V +1 11/13/25, 11:09

  13. Benjamin Franzke voted on patch set 4 CR +2 V +2 11/13/25, 11:51

  14. Benjamin Franzke merged patch set 5 11/13/25, 11:54