WordPress.org

Making WordPress.org


Ignore:
Timestamp:
11/23/17 05:51:26 (4 weeks ago)
Author:
dd32
Message:

Plugin Directory: Checksums: Move the checksums to their final URL, https://downloads.wordpress.org/plugin-checksums/$plugin/$version.json.

See #3192

File:
1 edited

Legend:

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

    r6022 r6163  
    3535     */ 
    3636    protected function determine_request() { 
    37         $zip = basename( parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) ); 
    38  
    39         if ( ! preg_match( "!^(?P<slug>[a-z0-9-_]+)(\.(?P<version>.+?))?\.(?P<request_type>zip|checksums\.json)$!i", $zip, $m ) ) { 
     37        $path = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ); 
     38        $zip  = basename( $path ); 
     39 
     40        if ( preg_match( "!^(?P<slug>[a-z0-9-_]+)(\.(?P<version>.+?))?\.zip$!i", $zip, $m ) ) { 
     41            // ZIP 
     42            $checksum_request = false; 
     43        } elseif ( preg_match( "!^/plugin-checksums/(?P<slug>[a-z0-9-_]+)/(?P<version>.+?)(\.json)?$!i", $path, $m ) ) { 
     44            // Checksums 
     45            $checksum_request = true; 
     46        } else { 
    4047            throw new Exception( __METHOD__ . ": Invalid URL." ); 
    4148        } 
     
    5158        } 
    5259 
    53         if ( 'zip' == strtolower( $m['request_type'] ) ) { 
    54             $checksum_request = false; 
    55         } else { 
    56             $checksum_request = true; 
    57  
    58             // Checksum requests for 'trunk' are not possible. 
    59             if ( 'trunk' == $version ) { 
    60                 throw new Exception( __METHOD__ . ": Checksum requests must include a version." ); 
    61             } 
    62  
     60        // Checksum requests for 'trunk' are not possible. 
     61        if ( $checksum_request && 'trunk' == $version ) { 
     62            throw new Exception( __METHOD__ . ": Checksum requests must include a version." ); 
    6363        } 
    6464 
Note: See TracChangeset for help on using the changeset viewer.