Make WordPress Core

Ticket #42609: 42609.diff

File 42609.diff, 1.4 KB (added by dd32, 7 years ago)
  • src/wp-admin/includes/file.php

    function wp_edit_theme_plugin_file( $arg 
    433433                        switch ( $type ) {
    434434                                case 'php':
    435435                                        $allowed_files = array_merge( $allowed_files, $theme->get_files( 'php', -1 ) );
    436436                                        break;
    437437                                case 'css':
    438438                                        $style_files = $theme->get_files( 'css', -1 );
    439439                                        $allowed_files['style.css'] = $style_files['style.css'];
    440440                                        $allowed_files = array_merge( $allowed_files, $style_files );
    441441                                        break;
    442442                                default:
    443443                                        $allowed_files = array_merge( $allowed_files, $theme->get_files( $type, -1 ) );
    444444                                        break;
    445445                        }
    446446                }
    447447
    448                 if ( 0 !== validate_file( $real_file, $allowed_files ) ) {
     448                if ( 0 !== validate_file( $file, array_keys( $allowed_files ) ) ) {
    449449                        return new WP_Error( 'disallowed_theme_file', __( 'Sorry, that file cannot be edited.' ) );
    450450                }
    451451
    452452                $is_active = ( get_stylesheet() === $stylesheet || get_template() === $stylesheet );
    453453        } else {
    454454                return new WP_Error( 'missing_theme_or_plugin' );
    455455        }
    456456
    457457        // Ensure file is real.
    458458        if ( ! is_file( $real_file ) ) {
    459459                return new WP_Error( 'file_does_not_exist', __( 'No such file exists! Double check the name and try again.' ) );
    460460        }
    461461
    462462        // Ensure file extension is allowed.
    463463        $extension = null;