Make WordPress Core

Ticket #33058: 33058.diff

File 33058.diff, 943 bytes (added by mkox, 3 years ago)

Check for empty filepath arg in exists method

  • src/wp-admin/includes/class-wp-filesystem-ftpext.php

    diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpext.php b/src/wp-admin/includes/class-wp-filesystem-ftpext.php
    index 627128fcac..48eed3b4a3 100644
    a b class WP_Filesystem_FTPext extends WP_Filesystem_Base { 
    412412         * Checks if a file or directory exists.
    413413         *
    414414         * @since 2.5.0
     415         * @since 6.0.0 returns false for empty filepath
    415416         *
    416417         * @param string $file Path to file or directory.
    417418         * @return bool Whether $file exists or not.
    418419         */
    419420        public function exists( $file ) {
     421               
     422                /**
     423                 * Check for empty filepath. If ftp_nlist gets an empty path,
     424                 * it checks the current working dir and may return true here.
     425                 *
     426                 * @ticket 33058
     427                 */
     428                if ( empty( $file ) ) {
     429                        return false;
     430                }
     431
    420432                $list = ftp_nlist( $this->link, $file );
    421433
    422434                if ( empty( $list ) && $this->is_dir( $file ) ) {