File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -1737,9 +1737,14 @@ private function remove_old_files_from_list( $files ) {
17371737 // 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- // Check symlink path directly without following it
1741- // Ensure the file path starts with ABSPATH
1742- if ( 0 !== strpos ( $ file_path , ABSPATH ) ) {
1740+ // Normalize the path to handle any .. sequences
1741+ $ normalized_path = realpath ( dirname ( $ file_path ) );
1742+ if ( false === $ normalized_path ) {
1743+ WP_CLI ::debug ( "Skipping symbolic link with invalid parent directory: {$ file }" , 'core ' );
1744+ continue ;
1745+ }
1746+ // Ensure the normalized parent directory is within ABSPATH
1747+ if ( 0 !== strpos ( Utils \trailingslashit ( $ normalized_path ), $ abspath_realpath_trailing ) && $ normalized_path !== rtrim ( $ abspath_realpath_trailing , '/ ' ) ) {
17431748 WP_CLI ::debug ( "Skipping symbolic link outside of ABSPATH: {$ file }" , 'core ' );
17441749 continue ;
17451750 }
You can’t perform that action at this time.
0 commit comments