Changeset 8484
- Timestamp:
- 03/21/2019 06:57:33 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-serve.php
r6287 r8484 38 38 $zip = basename( $path ); 39 39 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'] ); 43 44 } elseif ( preg_match( '!^/plugin-checksums/(?P<slug>[a-z0-9-_]+)/(?P<version>.+?)(\.json)?$!i', $path, $m ) ) { 44 45 // Checksums 45 $checksum_request = true; 46 $checksum_request = true; 47 $signature_request = false; 46 48 } else { 47 49 throw new Exception( __METHOD__ . ': Invalid URL.' ); … … 67 69 ); 68 70 69 if ( $checksum_request ) {71 if ( $checksum_request || $signature_request ) { 70 72 $args['stats'] = false; 71 73 … … 77 79 } 78 80 79 return compact( 'zip', 'slug', 'version', 'args', 'checksum_request' );81 return compact( 'zip', 'slug', 'version', 'args', 'checksum_request', 'signature_request' ); 80 82 } 81 83 … … 145 147 146 148 } elseif ( empty( $request['version'] ) || 'trunk' == $request['version'] ) { 147 return"{$request['slug']}/{$request['slug']}.zip";149 $file = "{$request['slug']}/{$request['slug']}.zip"; 148 150 149 151 } 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; 153 161 } 154 162 … … 166 174 if ( $request['checksum_request'] ) { 167 175 header( 'Content-Type: application/json' ); 176 } elseif ( $request['signature_request'] ) { 177 header( 'Content-Type: text/plain' ); 168 178 } else { 169 179 header( 'Content-Type: application/zip' );
Note: See TracChangeset
for help on using the changeset viewer.