Review main Merged

80983[BUGFIX] Avoid redirect loop for empty redirect url

Stefan Bürk CR +2 V +2 Easy +17 −1 updated 09/28/23, 09:22

Commit message

Sending a redirect response with a empty `Location` is
invalid per RFC. Browser vendor are dealing differntly
with it.

* Firefox executes a redirect to the current url, leading
  to an `endless` redirect chain - stopping it after some
  recursions with a coresponding notice in the network tab.
* Chrome determines this and is doing nothing at all with
  it - leading to a white page.

From the [1] RFC regarding invalid URI spec for `Location`:

> Note: Some recipients attempt to recover from Location
>       fields that are not valid URI references. This
>       specification does not mandate or define such
>       processing, but does allow it for the sake of
>       robustness.

A matching redirect record with a manually entered `/` as
redirect target leads in TYPO3 v11 to this behaviour. This
can be mitigated by selecting the corresponding site root.

For TYPO3 v12 and upwards a change in the LinkHandling has
been introduced which properly handles the `/` in the link
generation and correctly returning a `/` as redirect url.
That change has quite some impact and is not reasonable to
be backported to TYPO3 v11 within #100958.

This change adds an additionally guard to the `RedirectHandler`
to handle empty redirect urls as endless loop, just logging
it and not responding with an redirect. This helps in v11 and
keeps a safety guard for the future in this place.

[1] https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.2

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Oliver Klee +1
    • Rafael Kähm +1
    • Benni Mack +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Rafael Kähm +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 2

Files 1

Review log 2228

Show 23 earlier messages
  1. Stefan Bürk uploaded patch set 1 09/12/23, 12:35

  2. Stefan Bürk updated the commit message in patch set 2 09/12/23, 12:40

  3. core-ci voted on patch set 1 V +1 09/12/23, 12:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46515

  1. Stefan Bürk updated the commit message in patch set 3 09/12/23, 12:43

  2. core-ci voted on patch set 2 V +1 09/12/23, 12:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46516

  3. Stefan Bürk updated the commit message in patch set 4 09/12/23, 12:51

  4. core-ci voted on patch set 3 V +1 09/12/23, 12:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46517

  5. core-ci voted on patch set 4 V +1 09/12/23, 12:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46518

  6. Oliver Klee voted on patch set 4 CR +1 09/12/23, 13:21

  7. Stefan Bürk rebased onto patch set 5 CR +1 V +1 09/20/23, 14:49

  8. Oliver Klee voted on patch set 5 CR +1 09/20/23, 14:51

  9. core-ci voted on patch set 5 V +1 09/20/23, 14:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/46902

  10. Rafael Kähm commented on patch set 5 V +1 CR +1 09/21/23, 06:12

    Thanks for fixing that issue.
  11. Thomas Hohn voted on patch set 5 CR +1 09/22/23, 16:20

  12. Simon Schaufelberger commented on patch set 5 09/27/23, 15:22

    I suggest to install/activate a spellcheck ;)
    an endless
    an additional
  13. Stefan Bürk updated the commit message in patch set 6 CR +1 V +1 09/27/23, 15:43

  14. Stefan Bürk commented on patch set 6 09/27/23, 15:44

    Reply

    Not aware of one for the cli.

    Reply

    Done

    Reply

    Done
  15. core-ci voted on patch set 6 V +1 09/27/23, 15:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/47256

  16. Oliver Klee voted on patch set 6 CR +1 09/27/23, 16:03

  17. Simon Schaufelberger commented on patch set 6 09/27/23, 16:11

    Reply

    ah ok, I always use phpstorm to commit as well. I also use the https://plugins.jetbrains.com/plugin/7272-gerrit plugin The only downside is that I can't use github source with it so fetching data is slow.
  18. Benni Mack voted on patch set 6 V +1 CR +1 09/27/23, 16:47

  19. Benjamin Franzke commented on patch set 6 09/27/23, 18:21

    How can this be reproduced? You stated in https://forge.typo3.org/issues/100791#note-6 that you are not able to reproduce the issue, so, how did you manage to do so in the meantime?
  20. Benni Mack commented on patch set 6 09/27/23, 18:23

    with a wrong entry in sys_redirects
  21. Stefan Bürk commented on patch set 6 09/27/23, 18:38

    Reply

    main + 12 is as safety guard, in 11 it's easy: * v11 mono repo * install styleguide -> frontend demo page tree * change the base of the frontend demo site configuration from `/styleguide-demo-*` to `/` without a domain, only the slash. * create a sys_redirect record, can be done in over the gui: normal (not regexp) redirect, for source_path simply enter a random not existing path, e.g "/some/path/which/does/not/exists/" and as target simply enter a "/" into the input field (not using the link browser or something like that) and save the record. * Open "https://monorepo.tld/some/path/which/does/not/exists/"; IN chrome, simply nothing happens and you get a simple white page. Using firefox you can see in the network tap several redirects until it stops with the redirect loop info. main/v12 is fixed with our changes regarding the link handling and legacy linkbuilder stuff handling "folder => url" which we discussed and have done during the last community sprint. Talked with Benni, that was quite some changes not easily backportable to v11. Therefore, I decided to add this safety guard - and also to main/12.4 - to mitigate if with some changes in the future and a emtpy redirect url would be generated, eventuall by some events and so on, we have this safety net and don't handle it (ending in a 404 instead). If I was to unclear, ping me on slack and I can show you it in a screen share or add screenshots to the issue.
  22. Stefan Bürk commented on patch set 6 09/27/23, 18:43

    Reply

    Not tested with a directly added record to the table with a empty target - "/" should not lead to it in v12+.
  23. Rafael Kähm voted on patch set 6 V +1 CR +1 09/28/23, 06:25

  24. Stefan Bürk voted on patch set 6 V +2 CR +2 09/28/23, 09:07

  25. Stefan Bürk merged patch set 7 09/28/23, 09:22