Make WordPress Core

Changeset 31681


Ignore:
Timestamp:
03/09/2015 02:10:36 AM (10 years ago)
Author:
wonderboymusic
Message:

There are a few functions that have the ability to return false instead of a string, so the return value should be checked before being passed to functions that expect string.

These are trivial, but they clear out some Scrutinizer issues.

See #30799.

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-advanced.php

    r31645 r31681  
    427427 */
    428428do_action( 'post_edit_form_tag', $post );
     429
     430$referer = wp_get_referer();
    429431?>>
    430432<?php wp_nonce_field($nonce_action); ?>
     
    435437<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ) ?>" />
    436438<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status) ?>" />
    437 <input type="hidden" id="referredby" name="referredby" value="<?php echo esc_url(wp_get_referer()); ?>" />
     439<input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" />
    438440<?php if ( ! empty( $active_post_lock ) ) { ?>
    439441<input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
  • trunk/src/wp-admin/edit-form-comment.php

    r31641 r31681  
    169169do_meta_boxes(null, 'normal', $comment);
    170170
     171$referer = wp_get_referer();
    171172?>
    172173</div>
     
    174175<input type="hidden" name="c" value="<?php echo esc_attr($comment->comment_ID) ?>" />
    175176<input type="hidden" name="p" value="<?php echo esc_attr($comment->comment_post_ID) ?>" />
    176 <input name="referredby" type="hidden" id="referredby" value="<?php echo esc_url( wp_get_referer() ); ?>" />
     177<input name="referredby" type="hidden" id="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" />
    177178<?php wp_original_referer_field(true, 'previous'); ?>
    178179<input type="hidden" name="noredir" value="1" />
  • trunk/src/wp-admin/includes/class-wp-comments-list-table.php

    r31513 r31681  
    362362        $comment = $a_comment;
    363363        $the_comment_class = wp_get_comment_status( $comment->comment_ID );
     364        if ( ! $the_comment_class ) {
     365            $the_comment_class = '';
     366        }
    364367        $the_comment_class = join( ' ', get_comment_class( $the_comment_class, $comment->comment_ID, $comment->comment_post_ID ) );
    365368
  • trunk/src/wp-admin/includes/post.php

    r31392 r31681  
    12211221    if ( $ptype->hierarchical ) {
    12221222        $uri = get_page_uri($post);
    1223         $uri = untrailingslashit($uri);
    1224         $uri = strrev( stristr( strrev( $uri ), '/' ) );
    1225         $uri = untrailingslashit($uri);
     1223        if ( $uri ) {
     1224            $uri = untrailingslashit($uri);
     1225            $uri = strrev( stristr( strrev( $uri ), '/' ) );
     1226            $uri = untrailingslashit($uri);
     1227        }
    12261228
    12271229        /** This filter is documented in wp-admin/edit-tag-form.php */
  • trunk/src/wp-admin/network/themes.php

    r31200 r31681  
    175175                    <?php submit_button( _n( 'Yes, Delete this theme', 'Yes, Delete these themes', $themes_to_delete ), 'button', 'submit', false ); ?>
    176176                </form>
    177                 <form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
     177                <?php
     178                $referer = wp_get_referer();
     179                ?>
     180                <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;">
    178181                    <?php submit_button( __( 'No, Return me to the theme list' ), 'button', 'submit', false ); ?>
    179182                </form>
  • trunk/src/wp-admin/plugins.php

    r31333 r31681  
    322322                    <?php submit_button( $data_to_delete ? __( 'Yes, Delete these files and data' ) : __( 'Yes, Delete these files' ), 'button', 'submit', false ); ?>
    323323                </form>
    324                 <form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
     324                <?php
     325                $referer = wp_get_referer();
     326                ?>
     327                <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;">
    325328                    <?php submit_button( __( 'No, Return me to the plugin list' ), 'button', 'submit', false ); ?>
    326329                </form>
  • trunk/src/wp-admin/upgrade.php

    r31124 r31681  
    8282    case 0:
    8383        $goback = wp_get_referer();
    84         $goback = esc_url_raw( $goback );
    85         $goback = urlencode( $goback );
     84        if ( $goback ) {
     85            $goback = esc_url_raw( $goback );
     86            $goback = urlencode( $goback );
     87        }
    8688?>
    8789<h2><?php _e( 'Database Update Required' ); ?></h2>
  • trunk/src/wp-includes/class-http.php

    r31290 r31681  
    183183            if ( $r['reject_unsafe_urls'] )
    184184                $url = wp_http_validate_url( $url );
    185             $url = wp_kses_bad_protocol( $url, array( 'http', 'https', 'ssl' ) );
     185            if ( $url ) {
     186                $url = wp_kses_bad_protocol( $url, array( 'http', 'https', 'ssl' ) );
     187            }
    186188        }
    187189
  • trunk/src/wp-includes/theme.php

    r31224 r31681  
    10511051 * @since 2.1.0
    10521052 *
    1053  * @return string
     1053 * @return string|false
    10541054 */
    10551055function get_header_image() {
     
    11541154 */
    11551155function header_image() {
    1156     echo esc_url( get_header_image() );
     1156    $image = get_header_image();
     1157    if ( $image ) {
     1158        echo esc_url( $image );
     1159    }
    11571160}
    11581161
Note: See TracChangeset for help on using the changeset viewer.