WordPress.org

Make WordPress Core

Ticket #8497: 8497.3.diff

File 8497.3.diff, 5.6 KB (added by Denis-de-Bernardy, 9 years ago)

fix potential cron job issues

  • wp-includes/theme.php

     
    162162 * @return array Theme data.
    163163 */
    164164function get_theme_data( $theme_file ) {
     165        if( !function_exists( '_cleanup_header_comment' ) )
     166                require_once( ABSPATH . 'wp-admin/includes/misc.php' );
     167
    165168        $themes_allowed_tags = array(
    166169                'a' => array(
    167170                        'href' => array(),'title' => array()
     
    180183        $theme_data = implode( '', file( $theme_file ) );
    181184        $theme_data = str_replace ( '\r', '\n', $theme_data );
    182185        if ( preg_match( '|Theme Name:(.*)$|mi', $theme_data, $theme_name ) )
    183                 $name = $theme = wp_kses( trim( $theme_name[1] ), $themes_allowed_tags );
     186                $name = $theme = wp_kses( _cleanup_header_comment($theme_name[1]), $themes_allowed_tags );
    184187        else
    185188                $name = $theme = '';
    186189
    187190        if ( preg_match( '|Theme URI:(.*)$|mi', $theme_data, $theme_uri ) )
    188                 $theme_uri = clean_url( trim( $theme_uri[1] ) );
     191                $theme_uri = clean_url( _cleanup_header_comment($theme_uri[1]) );
    189192        else
    190193                $theme_uri = '';
    191194
    192195        if ( preg_match( '|Description:(.*)$|mi', $theme_data, $description ) )
    193                 $description = wptexturize( wp_kses( trim( $description[1] ), $themes_allowed_tags ) );
     196                $description = wptexturize( wp_kses( _cleanup_header_comment($description[1]), $themes_allowed_tags ) );
    194197        else
    195198                $description = '';
    196199
    197200        if ( preg_match( '|Author URI:(.*)$|mi', $theme_data, $author_uri ) )
    198                 $author_uri = clean_url( trim( $author_uri[1]) );
     201                $author_uri = clean_url( _cleanup_header_comment($author_uri[1]) );
    199202        else
    200203                $author_uri = '';
    201204
    202205        if ( preg_match( '|Template:(.*)$|mi', $theme_data, $template ) )
    203                 $template = wp_kses( trim( $template[1] ), $themes_allowed_tags );
     206                $template = wp_kses( _cleanup_header_comment($template[1]), $themes_allowed_tags );
    204207        else
    205208                $template = '';
    206209
    207210        if ( preg_match( '|Version:(.*)|i', $theme_data, $version ) )
    208                 $version = wp_kses( trim( $version[1] ), $themes_allowed_tags );
     211                $version = wp_kses( _cleanup_header_comment($version[1]), $themes_allowed_tags );
    209212        else
    210213                $version = '';
    211214
    212215        if ( preg_match('|Status:(.*)|i', $theme_data, $status) )
    213                 $status = wp_kses( trim( $status[1] ), $themes_allowed_tags );
     216                $status = wp_kses( _cleanup_header_comment($status[1]), $themes_allowed_tags );
    214217        else
    215218                $status = 'publish';
    216219
    217220        if ( preg_match('|Tags:(.*)|i', $theme_data, $tags) )
    218                 $tags = array_map( 'trim', explode( ',', wp_kses( trim( $tags[1] ), array() ) ) );
     221                $tags = array_map( 'trim', explode( ',', wp_kses( _cleanup_header_comment($tags[1]), array() ) ) );
    219222        else
    220223                $tags = array();
    221224
    222225        if ( preg_match( '|Author:(.*)$|mi', $theme_data, $author_name ) ) {
    223226                if ( empty( $author_uri ) ) {
    224                         $author = wp_kses( trim( $author_name[1] ), $themes_allowed_tags );
     227                        $author = wp_kses( _cleanup_header_comment($author_name[1]), $themes_allowed_tags );
    225228                } else {
    226                         $author = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $author_uri, __( 'Visit author homepage' ), wp_kses( trim( $author_name[1] ), $themes_allowed_tags ) );
     229                        $author = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $author_uri, __( 'Visit author homepage' ), wp_kses( _cleanup_header_comment($author_name[1]), $themes_allowed_tags ) );
    227230                }
    228231        } else {
    229232                $author = __('Anonymous');
  • wp-admin/includes/plugin.php

     
    6666 * @return array See above for description.
    6767 */
    6868function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
     69        if( !function_exists( '_cleanup_header_comment' ) )
     70                require_once( ABSPATH . 'wp-admin/includes/misc.php' );
     71       
    6972        // We don't need to write to the file, so just open for reading.
    7073        $fp = fopen($plugin_file, 'r');
    7174
     
    8689
    8790        foreach ( array( 'name', 'uri', 'version', 'description', 'author_name', 'author_uri', 'text_domain', 'domain_path' ) as $field ) {
    8891                if ( !empty( ${$field} ) )
    89                         ${$field} = trim(${$field}[1]);
     92                        ${$field} = _cleanup_header_comment(${$field}[1]);
    9093                else
    9194                        ${$field} = '';
    9295        }
  • wp-admin/includes/file.php

     
    5252        elseif ( file_exists( WP_CONTENT_DIR . $file ) && is_file( WP_CONTENT_DIR . $file ) ) {
    5353                $template_data = implode( '', file( WP_CONTENT_DIR . $file ) );
    5454                if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ))
    55                         return $name[1] . ' Page Template';
     55                        return _cleanup_header_comment($name[1]) . ' Page Template';
    5656        }
    5757
    5858        return basename( $file );
  • wp-admin/includes/misc.php

     
    370370                exit;
    371371        }
    372372}
     373
     374
     375/**
     376 * Strip close comment and close php tags from file headers used by WP
     377 * See http://core.trac.wordpress.org/ticket/8497
     378 *
     379 * @since 2.8
     380**/
     381function _cleanup_header_comment($str) {
     382        return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str));
     383}
     384
  • wp-admin/includes/theme.php

     
    133133
    134134                        $name = '';
    135135                        if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) )
    136                                 $name = $name[1];
     136                                $name = _cleanup_header_comment($name[1]);
    137137
    138138                        if ( !empty( $name ) ) {
    139139                                $page_templates[trim( $name )] = basename( $template );