Making WordPress.org

Changeset 6026


Ignore:
Timestamp:
10/13/2017 11:31:06 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Plugin Directory: When searching for the main plugin file on upload, limit recursion depth to 1 level.

Scanning the deeper levels can grab the wrong data, e.g. if there's a sub-plugin with headers, it may be scanned instead of the main one.

Fixes #2804.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php

    r5996 r6026  
    264264    private function get_plugin_root( $dir ) {
    265265        $plugin_root  = '';
    266         $plugin_files = Filesystem::list_files( $dir, true /* Recursive */, '!\.php$!i' );
     266        $plugin_files = Filesystem::list_files( $dir, true /* Recursive */, '!\.php$!i', 1 /* Depth */ );
    267267
    268268        foreach ( $plugin_files as $plugin_file ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php

    r5841 r6026  
    6161        $this->plugin_dir = Filesystem::unzip( $zip_file );
    6262
    63         $plugin_files = Filesystem::list_files( $this->plugin_dir, true /* Recursive */, '!\.php$!i' );
     63        $plugin_files = Filesystem::list_files( $this->plugin_dir, true /* Recursive */, '!\.php$!i', 1 /* Depth */ );
    6464        foreach ( $plugin_files as $plugin_file ) {
    6565            $plugin_data = get_plugin_data( $plugin_file, false, false ); // No markup/translation needed.
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-filesystem.php

    r3512 r6026  
    8181     * @param bool   $recursive Optional. Whether to recurse into subdirectories. Default: false.
    8282     * @param string $pattern   Optional. A regular expression to match files against. Default: null.
     83     * @param int    $depth     Optional. Recursion depth. Default: -1 (infinite).
    8384     * @return array All files within the passed directory.
    8485     */
    85     public static function list_files( $directory, $recursive = false, $pattern = null ) {
     86    public static function list_files( $directory, $recursive = false, $pattern = null, $depth = -1 ) {
    8687        if ( $recursive ) {
    8788            $iterator = new \RecursiveIteratorIterator(
     
    8990                \RecursiveIteratorIterator::SELF_FIRST
    9091            );
     92
     93            if ( $depth > -1 ) {
     94                $iterator->setMaxDepth( $depth );
     95            }
    9196        } else {
    9297            $iterator = new \DirectoryIterator( $directory );
Note: See TracChangeset for help on using the changeset viewer.