Review main Merged

77777[BUGFIX] Avoid invalid array key accesses in ext:linkvalidator

Stefan Bürk CR +2 V +2 Normal +41 −20 updated 04/11/23, 11:03

Commit message

Ensure that invalid array key accesses are properly guarded.

Additionally, fix the id of a language label, which was
incorrect.

All used variables are now initialized at the beginning of
ExternalLinkType::getErrorMessage().

Previously, the $errorParams['errorType'] was initialized in
one case with the status code. This is now changed so that
the HTTP status code is written to $errorParams['errno'].

In order to provide a generic error message, if the error
message cannot be obtained otherwise, a new language label
is added.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Sybille Peters +1
  • Verified V +2 Done
    • Benni Mack +2
    • Sybille Peters +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 1012

  1. Stefan Bürk uploaded patch set 1 02/07/23, 18:33

  2. core-ci voted on patch set 1 V +1 02/07/23, 18:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37308

  3. Stefan Bürk commented on patch set 1 02/07/23, 18:41

    Backport prepared, needs dedicated voting - does a little more than main.
  4. Oliver Klee voted on patch set 1 CR +1 02/07/23, 18:47

  5. Christian Kuhn commented on patch set 1 02/08/23, 10:41

    ExternalLinktype.php:264

    there is no key 'list.report.error.httpstatuscode.0' in locallang.
  6. Sybille Peters commented on patch set 1 02/25/23, 11:17

    ExternalLinktype.php:264 Reply

    Theoretically if errno is empty or 0 there is no error so if that is the case something else is already wrong here. Might make sense to check that because this should not happen. (Still good idea to check for missing array entries unless sure). On a side not: I already wrote that in another patch (I think): Might improve to use a class instead of the errorParams. It is a bit flaky in some places. For brofix, I separated the error type (string with fixed set of types) and error code (number) and used a class, see https://github.com/sypets/brofix/blob/main/Classes/Linktype/ErrorParams.php The code could still use improvement but it's about the general idea.
  7. Sybille Peters commented on patch set 1 CR -1 02/25/23, 11:47

    See comment. Also, errorParams might benefit from converting to a class and using and initializing the values in a more clean and safe way but I understand this may not be the best time right now.

    ExternalLinktype.php:189

    I think this should get fixed here. It should be: $this->errorParams['errorType'] = $response->getStatusCode(); In other places, errno is used. This statement is in the try block. In most (or all cases of error) an exception is thrown but should still make sure to set correctly. Also, the values could be initialized to a sane value at the beginning (then you don't need all the null coalesce later).
  8. Sybille Peters uploaded patch set 2 CR +1 V +1 02/26/23, 18:57

  9. Sybille Peters commented on patch set 2 V +1 CR +1 02/26/23, 19:00

    ExternalLinktype.php:189 Reply

    Done

    ExternalLinktype.php:264 Reply

    I change the switch case so that all cases use an explicit language label. I also fixed the language label list.report.error.httpstatuscode.305 (before, 300 was listed twice) and use a generic one in the default.
  10. core-ci voted on patch set 2 V +1 02/26/23, 19:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38129

  11. Benni Mack voted on patch set 2 V +2 CR +2 04/11/23, 11:03

  12. Benni Mack merged patch set 3 04/11/23, 11:03