Making WordPress.org

Changeset 8484


Ignore:
Timestamp:
03/21/2019 06:57:33 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: ZIPs: Allow serving ZIP signature files at $zip_url.sig as used by r8483 and Core.

Currently no plugins ZIPs have signatures, but these will be generated after some WordPress.org changes.

See #4308.
See https://core.trac.wordpress.org/ticket/39309.

File:
1 edited

Legend:

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

    r6287 r8484  
    3838        $zip  = basename( $path );
    3939
    40         if ( preg_match( '!^(?P<slug>[a-z0-9-_]+)(\.(?P<version>.+?))?\.zip$!i', $zip, $m ) ) {
    41             // ZIP
    42             $checksum_request = false;
     40        if ( preg_match( '!^(?P<slug>[a-z0-9-_]+)(\.(?P<version>.+?))?\.zip(?P<signature>\.sig)?$!i', $zip, $m ) ) {
     41            // ZIP or Signature
     42            $checksum_request  = false;
     43            $signature_request = isset( $m['signature'] );
    4344        } elseif ( preg_match( '!^/plugin-checksums/(?P<slug>[a-z0-9-_]+)/(?P<version>.+?)(\.json)?$!i', $path, $m ) ) {
    4445            // Checksums
    45             $checksum_request = true;
     46            $checksum_request  = true;
     47            $signature_request = false;
    4648        } else {
    4749            throw new Exception( __METHOD__ . ': Invalid URL.' );
     
    6769        );
    6870
    69         if ( $checksum_request ) {
     71        if ( $checksum_request || $signature_request ) {
    7072            $args['stats'] = false;
    7173
     
    7779        }
    7880
    79         return compact( 'zip', 'slug', 'version', 'args', 'checksum_request' );
     81        return compact( 'zip', 'slug', 'version', 'args', 'checksum_request', 'signature_request' );
    8082    }
    8183
     
    145147
    146148        } elseif ( empty( $request['version'] ) || 'trunk' == $request['version'] ) {
    147             return "{$request['slug']}/{$request['slug']}.zip";
     149            $file = "{$request['slug']}/{$request['slug']}.zip";
    148150
    149151        } else {
    150             return "{$request['slug']}/{$request['slug']}.{$request['version']}.zip";
    151         }
    152 
     152            $file = "{$request['slug']}/{$request['slug']}.{$request['version']}.zip";
     153        }
     154
     155        // Signature requests are valid for any ZIP requests, but not checksums.
     156        if ( $request['signature_request'] ) {
     157            $file .= '.sig';
     158        }
     159
     160        return $file;
    153161    }
    154162
     
    166174            if ( $request['checksum_request'] ) {
    167175                header( 'Content-Type: application/json' );
     176            } elseif ( $request['signature_request'] ) {
     177                header( 'Content-Type: text/plain' );
    168178            } else {
    169179                header( 'Content-Type: application/zip' );
Note: See TracChangeset for help on using the changeset viewer.