Making WordPress.org

Changeset 10050


Ignore:
Timestamp:
07/10/2020 02:46:17 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Add some restrictions on the size of asset files to import.

The initial limits are:

  • Screenshots: 10MB, very few are larger than this.
  • Banners: 4MB (Low & High res)
  • Icons: 1MB

See #5171.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r10046 r10050  
    417417                );
    418418
     419                $asset_limits = array(
     420                        'screenshot' => 10 * MB_IN_BYTES,
     421                        'banner'     => 4 * MB_IN_BYTES,
     422                        'icon'       => 1 * MB_IN_BYTES,
     423                );
     424
    419425                $svn_assets_folder = SVN::ls( self::PLUGIN_SVN_BASE . "/{$plugin_slug}/assets/", true /* verbose */ );
    420426                if ( $svn_assets_folder ) { // /assets/ may not exist.
     
    425431                                }
    426432
     433                                // Don't import oversize assets.
     434                                if ( $asset['filesize'] > $asset_limits[ $m['type'] ] ) {
     435                                        continue;
     436                                }
     437
    427438                                $type       = $m['type'];
    428439                                $filename   = $asset['filename'];
     
    444455                        if ( isset( $assets['screenshot'][ $filename ] ) ) {
    445456                                // Skip it, it exists within /assets/ already
     457                                continue;
     458                        }
     459
     460                        // Don't import oversize assets.
     461                        if ( filesize( $plugin_screenshot ) > $asset_limits['screenshot'] ) {
    446462                                continue;
    447463                        }
Note: See TracChangeset for help on using the changeset viewer.