Making WordPress.org


Ignore:
Timestamp:
06/02/2016 08:25:35 AM (8 years ago)
Author:
dd32
Message:

Plugin Directory: Execute the ZIP & SVN commands with an appropriate UTF-8 character set.

See #1578

File:
1 edited

Legend:

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

    r3212 r3291  
    114114
    115115        // Cleanup any symlinks that shouldn't be there
    116         exec( sprintf(
     116        $this->exec( sprintf(
    117117            'find %s -type l -print0 | xargs -r0 rm',
    118118            escapeshellarg( $build_dir )
     
    133133    protected function fix_directory_dates() {
    134134        // Find all files, output their modified dates, sort reverse numerically, grab the timestamp from the first entry
    135         $latest_file_modified_timestamp = exec( sprintf(
     135        $latest_file_modified_timestamp = $this->exec( sprintf(
    136136            "find %s -type f -printf '%%T@\n' | sort -nr | head -c 10",
    137137            escapeshellarg( $this->tmp_build_dir )
     
    141141        }
    142142
    143         exec( sprintf(
     143        $this->exec( sprintf(
    144144            'find %s -type d -exec touch -m -t %s {} \;',
    145145            escapeshellarg( $this->tmp_build_dir ),
     
    154154        // We have to remove the temporary 0-byte file first as zip will complain about not being able to find the zip structures.
    155155        unlink( $this->tmp_build_file );
    156         exec( $cmd = sprintf(
     156        $this->exec( sprintf(
    157157            'cd %s && find %s -print0 | sort -z | xargs -0 zip -Xu %s 2>&1',
    158158            escapeshellarg( $this->tmp_build_dir ),
     
    169169     * Moves the completed ZIP into it's real-life location.
    170170     */
    171     function move_into_place() {
    172         exec( sprintf(
     171    protected function move_into_place() {
     172        $this->exec( sprintf(
    173173            'mv -f %s %s',
    174174            $this->tmp_build_file,
     
    186186     * This can also be used for generating a package signature in the future.
    187187     */
    188     function generate_md5() {
    189         exec( sprintf(
     188    protected function generate_md5() {
     189        $this->exec( sprintf(
    190190            "md5sum %s | head -c 32 > %s",
    191191            escapeshellarg( $this->zip_file ),
     
    206206        }
    207207        if ( $this->tmp_build_dir ) {
    208             exec( sprintf( 'rm -rf %s', escapeshellarg( $this->tmp_build_dir ) ) );
    209         }
    210     }
     208            $this->exec( sprintf( 'rm -rf %s', escapeshellarg( $this->tmp_build_dir ) ) );
     209        }
     210    }
     211
     212    /**
     213     * Executes a command with 'proper' locale/language settings
     214     * so that utf8 strings are handled correctly.
     215     *
     216     * WordPress.org uses the en_US.UTF-8 locale.
     217     */
     218    protected function exec( $command, &$output = null, &$return_val = null ) {
     219        return exec( 'export LC_CTYPE="en_US.UTF-8" LANG="en_US.UTF-8"; ' . $command, $output, $return_val );
     220    }
     221
    211222}
    212223
Note: See TracChangeset for help on using the changeset viewer.