Making WordPress.org


Ignore:
Timestamp:
12/15/2017 01:45:55 AM (9 years ago)
Author:
dd32
Message:

Plugin Directory: Checksums: Correctly handle filenames with spaces, previously the filename was being truncated.

Props krisshannon.
Fixes #3335.

File:
1 edited

Legend:

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

    r6184 r6280  
    202202                $existing_json_checksum_file = file_exists( $this->checksum_file );
    203203
     204                $skip_bad_files = array();
    204205                $checksums = array();
    205206                foreach ( array( 'md5' => 'md5sum', 'sha256' => 'sha256sum' ) as $checksum_type => $checksum_bin ) {
     207                        $checksum_output = array();
    206208                        $this->exec( sprintf(
    207209                                'cd %s && find . -type f -print0 | sort -z | xargs -0 ' . $checksum_bin . ' 2>&1',
    … …  
    216218
    217219                        foreach ( $checksum_output as $line ) {
    218                                 list( $checksum, $filename ) = preg_split( '!\s+!', $line );
     220                                list( $checksum, $filename ) = preg_split( '!\s+!', $line, 2 );
    219221                                $filename = trim( preg_replace( '!^./!', '', $filename ) );
    220222                                $checksum = trim( $checksum );
     223
     224                                // See https://meta.trac.wordpress.org/ticket/3335 - Filenames like 'Testing Test' truncated to 'Testing'
     225                                if ( preg_match( '!^(\S+)\s+\S!', $filename, $m ) ) {
     226                                        $skip_bad_files[ $m[1] ] = true;
     227                                }
    221228
    222229                                if ( ! isset( $checksums[ $filename ] ) ) {
    … …  
    259266                        // Combine Checksums from existing files and the new files
    260267                        foreach ( $existing_json_checksum_file->files as $file => $checksums ) {
     268                                if ( isset( $skip_bad_files[ $file ] ) ) {
     269                                        // See https://meta.trac.wordpress.org/ticket/3335
     270                                        // This is a partial filename, which shouldn't have been in the checksums.
     271                                        continue;
     272                                }
    261273                                if ( ! isset( $json_checksum_file->files[ $file ] ) ) {
    262274                                        // Deleted file, use existing checksums.
Note: See TracChangeset for help on using the changeset viewer.