Review main Merged

70913[TASK] Add a PathUtility method to check for host-absolute URLs

Helmut Hummel CR +2 V +2 Normal +59 −9 updated 09/14/21, 17:33

Commit message

This replaces a lot of string-based comparisons spread around
the code, which have been even wrong.
Having a single place for this kind of checks is beneficial.

The method is added to PathUtility as similar methods are already
present there.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Markus Klein +1
    • Oliver Hader +1
  • Verified V +2 Done
    • Benni Mack +2
    • Markus Klein +1
    • core-ci +1 CI

Issues 1

Files 9

Review log 2632

Show 47 earlier messages
  1. Helmut Hummel uploaded patch set 1 09/06/21, 13:17

  2. core-ci voted on patch set 1 V -1 09/06/21, 13:39 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16323

  3. Markus Klein uploaded patch set 2 09/06/21, 14:24

  4. core-ci voted on patch set 2 V -1 09/06/21, 14:40 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16329

  5. Markus Klein uploaded patch set 3 09/06/21, 14:56

  6. core-ci voted on patch set 3 V +1 09/06/21, 15:12 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16332

  7. Markus Klein voted on patch set 3 V +1 CR +1 09/06/21, 15:12

  1. Markus Klein updated the commit message in patch set 4 09/06/21, 15:13

  2. Markus Klein voted on patch set 4 V +1 CR +1 09/06/21, 15:13

  3. core-ci voted on patch set 4 V +1 09/06/21, 15:29 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16333

  4. Mathias Brodala commented on patch set 4 09/06/21, 15:35

    HttpUtility.php:108

    For HTTP this should explicitly check that the $path starts with "http://"; or "https://";. Otherwise this method would make more sense in a general "UriUtility".
  5. Markus Klein commented on patch set 4 09/06/21, 15:40

    HttpUtility.php:108 Reply

    Any idea where else to put this, besides creating a new utitility?
  6. Mathias Brodala commented on patch set 4 09/06/21, 15:46

    HttpUtility.php:108 Reply

    Not many options here. Using "TYPO3\CMS\Core\Http\Uri" would be a bit too much and not be as clear. So ATM a new utility class would make sense.
  7. Oliver Hader commented on patch set 4 09/07/21, 09:08

    Can you please (briefly) describe in the commit message, why this is necessary? Thx

    HttpUtilityTest.php:161

    Probably those would should be `false` then, correct? * `/example.com/demo.html` * `example.com/demo.html` * `demo.html` What about ports, user, fragment? * `http://example.com:8080/demo.html` * `https://user:pass@example.com/demo.html` * `https://example.com/demo.html#fragment`
  8. Markus Klein commented on patch set 4 09/07/21, 10:40

    Reply

    Will do, once Mathias' comment is resolved

    HttpUtility.php:108 Reply

    Okay, please decide that in the Core team, if we really want a new Utility for this line of code?!?!

    HttpUtilityTest.php:161 Reply

    Correct. ports, fragements, etc do not matter for this method.
  9. Mathias Brodala commented on patch set 4 09/07/21, 10:47

    HttpUtility.php:108 Reply

    I'm not with the Core team and don't think we need to consult many people about this. If we mark this method as @internal we should be free to move it around later if we find a more suitable location.
  10. Helmut Hummel commented on patch set 4 09/07/21, 10:57

    HttpUtility.php:108 Reply

    Interestingly, I initially put this method in PathUtility, as it is mostly used in a context where a given path is checked whether it looks like an url. And with the discussion here, I tend to put it back there and name it resemblesurl https://review.typo3.org/c/Packages/TYPO3.CMS/+/70839/5/typo3/sysext/core/Classes/Utility/PathUtility.php#26
  11. Markus Klein uploaded patch set 5 09/07/21, 11:13

  12. Markus Klein commented on patch set 5 09/07/21, 11:14

    HttpUtility.php:108 Reply

    Done

    HttpUtilityTest.php:161 Reply

    Done
  13. Mathias Brodala commented on patch set 5 09/07/21, 11:18

    PathUtilityTest.php:568

    Can we add "f:/example.com/demo.html" as another example? Also maybe one version with backslashes since this is about file paths. Better be explicit about things we definitely don't want to accept here.
  14. core-ci voted on patch set 5 V -1 09/07/21, 11:18 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16374

  15. Markus Klein commented on patch set 5 09/07/21, 11:23

    PathUtilityTest.php:568 Reply

    Done
  16. Markus Klein uploaded patch set 6 09/07/21, 11:23

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

  18. Markus Klein voted on patch set 6 V +1 CR +1 09/07/21, 12:28

  19. Benni Mack commented on patch set 6 V +2 CR +2 09/07/21, 18:59

    Hope the change is OK with you now @mbrodala
  20. Benni Mack merged patch set 7 09/07/21, 18:59

  21. Simon Schaufelberger commented on patch set 7 09/08/21, 01:24

    PathUtilityTest.php:564

    This line is identical with the line above and nobody noticed 😄
  22. Mathias Brodala commented on patch set 7 09/08/21, 06:52

    Reply

    Yes. :-)
  23. Oliver Hader voted on patch set 7 CR +1 09/08/21, 07:03

  24. Markus Klein commented on patch set 7 09/08/21, 07:28

    PathUtilityTest.php:564 Reply

    Ctrl+D in phpstorm for the lines, when I created them :-D Better test twice... better safe than sorry... <insert any slogan here>
  25. Simon Schaufelberger commented on patch set 7 09/14/21, 17:33

    Created followup Patch: https://forge.typo3.org/issues/95215

    PathUtilityTest.php:564 Reply

    Done