Skip to content

Commit 6573b48

Browse files
Copilotswissspidy
andcommitted
Use pathinfo() and trailingslashit() for safer path handling
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 154f2a2 commit 6573b48

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/Core_Command.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ function wp_new_blog_notification() {
706706
$path = rtrim( $path, '/' );
707707
if ( empty( $path ) ) {
708708
$path = '/index.php';
709-
} elseif ( false === strpos( basename( $path ), '.' ) ) {
709+
} elseif ( '' === pathinfo( $path, PATHINFO_EXTENSION ) ) {
710710
// Path doesn't end with a file, append /index.php
711711
$path .= '/index.php';
712712
}
@@ -717,8 +717,8 @@ function wp_new_blog_notification() {
717717
// Set SCRIPT_FILENAME to the actual WordPress index.php if available.
718718
// This is optional and only set when ABSPATH is defined and index.php exists.
719719
// If not set, WordPress can still function using PHP_SELF and SCRIPT_NAME.
720-
if ( defined( 'ABSPATH' ) && file_exists( ABSPATH . 'index.php' ) ) {
721-
$_SERVER['SCRIPT_FILENAME'] = ABSPATH . 'index.php';
720+
if ( defined( 'ABSPATH' ) && file_exists( Utils\trailingslashit( ABSPATH ) . 'index.php' ) ) {
721+
$_SERVER['SCRIPT_FILENAME'] = Utils\trailingslashit( ABSPATH ) . 'index.php';
722722
}
723723
}
724724

0 commit comments

Comments
 (0)