Skip to content

Commit

Permalink
Remove the calls to realpath in FileIntegrity checks (#22723)
Browse files Browse the repository at this point in the history
* Remove the calls to realpath when collecting paths for display to the user. Calling realpath on a symlink that was found in the tree, for example, causes Matomo to suggest to the user deleting the target of the symlink. At best this would be a nuisance, and at worst it could be catastrophic (if the user kept a symlink to files outside of Matomo's directory, for example). Fixes #16551.

* Apply suggestions from code review

Incorporate @caddoo's suggested changes

Co-authored-by: caddoo <[email protected]>

* Fix style violations.

* Another whitespace style fix.

---------

Co-authored-by: caddoo <[email protected]>
  • Loading branch information
danielpunkass and caddoo authored Dec 23, 2024
1 parent f0dab35 commit e1bdd44
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/FileIntegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected static function getMessagesDirectoriesFoundButNotExpected($messages)

$directories = array();
foreach ($directoriesFoundButNotExpected as $directoryFoundNotExpected) {
$directories[] = htmlspecialchars(realpath($directoryFoundNotExpected));
$directories[] = htmlspecialchars(realpath(dirname($directoryFoundNotExpected)) . DIRECTORY_SEPARATOR . basename($directoryFoundNotExpected));
}

$deleteAllAtOnce = array();
Expand Down Expand Up @@ -138,7 +138,7 @@ protected static function getMessagesFilesFoundButNotExpected($messages)

$files = array();
foreach ($filesFoundButNotExpected as $fileFoundNotExpected) {
$files[] = '"' . htmlspecialchars(realpath($fileFoundNotExpected)) . '"';
$files[] = '"' . htmlspecialchars(realpath(dirname($fileFoundNotExpected)) . DIRECTORY_SEPARATOR . basename($fileFoundNotExpected)) . '"';
}

$deleteAllAtOnce = array();
Expand Down

0 comments on commit e1bdd44

Please sign in to comment.