Skip to content

Commit 9f699f1

Browse files
swissspidyCopilot
andauthored
Update src/WP_CLI/CommandWithUpgrade.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 584d505 commit 9f699f1

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ protected function install_from_php_file( $url, $assoc_args ) {
364364
$filename = Utils\basename( $url_path );
365365

366366
// Validate the filename doesn't contain directory separators or relative path components.
367+
// Note: Utils\basename() already strips directory components (including ".."), so this check
368+
// is primarily a defense-in-depth safeguard in case its behavior changes or is bypassed.
367369
if ( strpos( $filename, '/' ) !== false || strpos( $filename, '\\' ) !== false || strpos( $filename, '..' ) !== false ) {
368370
return new WP_Error( 'invalid_filename', 'The filename contains invalid path components.' );
369371
}

0 commit comments

Comments
 (0)