Issue Bug Closed

#103122FileLinkHandler: false return value not taken into account

Gernot Leitgab 02/14/24, 14:27 updated 07/09/24, 15:33

Description

With the latest security patch version 11.5.35 the following lines where added to “\TYPO3\CMS\Recordlist\LinkHandler\FileLinkHandler::render()”:

        if ($selectedFolder->getStorage()->isFallbackStorage()) {
            $selectedFolder = null;
        }

https://github.com/TYPO3-CMS/recordlist/compare/v11.5.34…v11.5.35#diff-606331e26a505d19f3d851b0ac8c71433f861a2074c9e31b5077088e7d8e69e1

The variable “$selectedFolder” can be “false”, because the previous line is “$selectedFolder = $this->getSelectedFolder($this->expandFolder);” and the return value of “getSelectedFolder()” can be a folder object or “false”. The “false” return value is not taken into account in the newly added code, which results in an exception.

Reviews 1

History 610

  1. Gernot Leitgab commented 02/14/24, 14:44

    Possible solution would be:

            if ($selectedFolder === false || $selectedFolder->getStorage()->isFallbackStorage()) {
                $selectedFolder = null;
            }
  2. Gerrit Code Review pushed patch set 1 for 11.5 to change 82999 status New Under Review 02/14/24, 15:18

  3. Gerrit Code Review pushed patch set 2 for 11.5 to change 82999 02/14/24, 15:18

  4. Gerrit Code Review pushed patch set 3 for 11.5 to change 82999 02/14/24, 15:30

  5. Markus Klein changed Duplicates #103116 02/14/24, 16:16

  6. Benjamin Franzke commented 02/14/24, 21:29

    Hi Gernot,

    The code in v11 is wrong and needs to be updated. Thanks for the report.
    One question: Did you actually run into the exception in v11, or did you face the error in an ELTS instance and noticed that the coding mistake is available in v11 as well?

    (I’m asking because I couldn’t reproduce in v11)

    Thanks, Benjamin

  7. Benjamin Franzke commented 02/14/24, 21:49

    nevermind, found it: getSelectedFolder() return false if backend user has no “default” upload folder, which is the case when all storages are marked non-writable. With that the error is actually reproducible in v11 when trying to create a new file link.

  8. Gerrit Code Review pushed patch set 4 for 11.5 to change 82999 02/14/24, 21:51

  9. Andreas Fernandez commented and changed status Under Review Resolved 02/15/24, 09:35

    Applied in changeset commit:de0f48a7099fb320c50fd4635e11c1e4015690d9.

  10. Benni Mack changed status Resolved Closed 07/09/24, 15:33