Skip to content

Commit 050a066

Browse files
Copilotswissspidy
andcommitted
Simplify symlink validation to check path directly without resolution
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 0c04d93 commit 050a066

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/Core_Command.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,12 +1734,12 @@ private function remove_old_files_from_list( $files ) {
17341734

17351735
$file_path = ABSPATH . $file;
17361736

1737-
// For symlinks, validate the symlink itself is within ABSPATH
1737+
// For symlinks, validate the symlink itself is within ABSPATH (not where it points)
17381738
// For other files, validate the real path is within ABSPATH
17391739
if ( is_link( $file_path ) ) {
1740-
// Validate the symlink path itself (not target) is within ABSPATH
1741-
$parent_dir_realpath = realpath( dirname( $file_path ) );
1742-
if ( false === $parent_dir_realpath || 0 !== strpos( $parent_dir_realpath, $abspath_realpath_trailing ) ) {
1740+
// Check symlink path directly without following it
1741+
// Ensure the file path starts with ABSPATH
1742+
if ( 0 !== strpos( $file_path, ABSPATH ) ) {
17431743
WP_CLI::debug( "Skipping symbolic link outside of ABSPATH: {$file}", 'core' );
17441744
continue;
17451745
}

0 commit comments

Comments
 (0)