WordPress.org

Making WordPress.org

Changeset 3291


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

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

See #1578

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 edited

Legend:

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

    r3215 r3291  
    3333        $esc_url  = escapeshellarg( $url );
    3434
    35         $output = shell_exec( "svn import $esc_options $esc_path $esc_url 2>&1" );
     35        $output = self::shell_exec( "svn import $esc_options $esc_path $esc_url 2>&1" );
    3636        if ( preg_match( '/Committed revision (?P<revision>\d+)[.]/i', $output, $m ) ) {
    3737            $revision = (int) $m['revision'];
     
    6464        $esc_destination = escapeshellarg( $destination );
    6565
    66         $output = shell_exec( "svn export $esc_options $esc_url $esc_destination 2>&1" );
     66        $output = self::shell_exec( "svn export $esc_options $esc_url $esc_destination 2>&1" );
    6767        if ( preg_match( '/Exported revision (?P<revision>\d+)[.]/i', $output, $m ) ) {
    6868            $revision = (int) $m['revision'];
     
    9494        $esc_url = escapeshellarg( $url );
    9595
    96         $output = shell_exec( "svn ls $esc_options $esc_url 2>&1" );
     96        $output = self::shell_exec( "svn ls $esc_options $esc_url 2>&1" );
    9797
    9898        $errors = self::parse_svn_errors( $output );
     
    163163        return false;
    164164    }
     165
     166    /**
     167     * Executes a command with 'proper' locale/language settings
     168     * so that utf8 strings are handled correctly.
     169     *
     170     * WordPress.org uses the en_US.UTF-8 locale.
     171     */
     172    protected static function shell_exec( $command ) {
     173        return shell_exec( 'export LC_CTYPE="en_US.UTF-8" LANG="en_US.UTF-8"; ' . $command );
     174    }
    165175}
  • 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.