Make WordPress Core

Ticket #17737: 17737.3.patch

File 17737.3.patch, 4.4 KB (added by SergeyBiryukov, 11 years ago)
  • src/wp-includes/query.php

     
    14601460                $qv['paged'] = absint($qv['paged']);
    14611461                $qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // comma separated list of positive or negative integers
    14621462                $qv['author'] = preg_replace( '|[^0-9,-]|', '', $qv['author'] ); // comma separated list of positive or negative integers
     1463                if ( is_array( $qv['pagename'] ) )
     1464                        $qv['pagename'] = current( $qv['pagename'] );
    14631465                $qv['pagename'] = trim( $qv['pagename'] );
     1466                if ( is_array( $qv['name'] ) )
     1467                        $qv['name'] = current( $qv['name'] );
    14641468                $qv['name'] = trim( $qv['name'] );
    14651469                if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']);
    14661470                if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']);
     
    17311735                                );
    17321736
    17331737                                if ( isset( $t->rewrite['hierarchical'] ) && $t->rewrite['hierarchical'] ) {
     1738                                        if ( is_array( $q[$t->query_var] ) )
     1739                                                $q[$t->query_var] = current( $q[$t->query_var] );
    17341740                                        $q[$t->query_var] = wp_basename( $q[$t->query_var] );
    17351741                                }
    17361742
     
    17531759
    17541760                // Category stuff
    17551761                if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular && $this->query_vars_changed ) {
    1756                         $q['cat'] = ''.urldecode($q['cat']).'';
    1757                         $q['cat'] = addslashes_gpc($q['cat']);
    1758                         $cat_array = preg_split('/[,\s]+/', $q['cat']);
     1762                        if ( is_array( $q['cat'] ) )
     1763                                $q['cat'] = current( $q['cat'] );
     1764                        $q['cat'] = urldecode( $q['cat'] );
     1765                        $q['cat'] = addslashes_gpc( $q['cat'] );
     1766                        $cat_array = preg_split( '/[,\s]+/', $q['cat'] );
    17591767                        $q['cat'] = '';
    17601768                        $req_cats = array();
    17611769                        foreach ( (array) $cat_array as $cat ) {
     
    20492057                        $q['page_id'] = get_option('page_on_front');
    20502058                }
    20512059
    2052                 if ( isset($q['page']) ) {
    2053                         $q['page'] = trim($q['page'], '/');
    2054                         $q['page'] = absint($q['page']);
     2060                if ( isset( $q['page'] ) ) {
     2061                        if ( is_array( $q['page'] ) )
     2062                                $q['page'] = current( $q['page'] );
     2063                        $q['page'] = trim( $q['page'], '/' );
     2064                        $q['page'] = absint( $q['page'] );
    20552065                }
    20562066
    20572067                // If true, forcibly turns off SQL_CALC_FOUND_ROWS even when limits are present.
     
    21892199                                }
    21902200                        }
    21912201                } elseif ( '' != $q['attachment'] ) {
     2202                        if ( is_array( $q['attachment'] ) )
     2203                                $q['attachment'] = current( $q['attachment'] );
    21922204                        $q['attachment'] = sanitize_title_for_query( wp_basename( $q['attachment'] ) );
    21932205                        $q['name'] = $q['attachment'];
    21942206                        $where .= " AND $wpdb->posts.post_name = '" . $q['attachment'] . "'";
     
    22332245                // If a search pattern is specified, load the posts that match
    22342246                if ( !empty($q['s']) ) {
    22352247                        // added slashes screw with quote grouping when done early, so done later
    2236                         $q['s'] = stripslashes($q['s']);
     2248                        if ( is_array( $q['s'] ) )
     2249                                $q['s'] = current( $q['s'] );
     2250                        $q['s'] = stripslashes( $q['s'] );
    22372251                        if ( empty( $_GET['s'] ) && $this->is_main_query() )
    2238                                 $q['s'] = urldecode($q['s']);
     2252                                $q['s'] = urldecode( $q['s'] );
    22392253                        if ( !empty($q['sentence']) ) {
    22402254                                $q['search_terms'] = array($q['s']);
    22412255                        } else {
     
    23462360                // Author/user stuff
    23472361
    23482362                if ( ! empty( $q['author'] ) && $q['author'] != '0' ) {
    2349                         $q['author'] = addslashes_gpc( '' . urldecode( $q['author'] ) );
     2363                        if ( is_array( $q['author'] ) )
     2364                                $q['author'] = current( $q['author'] );
     2365                        $q['author'] = urldecode( $q['author'] );
     2366                        $q['author'] = addslashes_gpc( $q['author'] );
    23502367                        $authors = array_unique( array_map( 'intval', preg_split( '/[,\s]+/', $q['author'] ) ) );
    23512368                        foreach ( $authors as $author ) {
    23522369                                $key = $author > 0 ? 'author__in' : 'author__not_in';
     
    23662383                // Author stuff for nice URLs
    23672384
    23682385                if ( '' != $q['author_name'] ) {
     2386                        if ( is_array( $q['author_name'] ) )
     2387                                $q['author_name'] = current( $q['author_name'] );
    23692388                        if ( strpos($q['author_name'], '/') !== false ) {
    23702389                                $q['author_name'] = explode('/', $q['author_name']);
    23712390                                if ( $q['author_name'][ count($q['author_name'])-1 ] ) {
     
    24082427                                $allowed_keys[] = 'meta_value';
    24092428                                $allowed_keys[] = 'meta_value_num';
    24102429                        }
    2411                         $q['orderby'] = urldecode($q['orderby']);
    2412                         $q['orderby'] = addslashes_gpc($q['orderby']);
     2430                        if ( is_array( $q['orderby'] ) )
     2431                                $q['orderby'] = current( $q['orderby'] );
     2432                        $q['orderby'] = urldecode( $q['orderby'] );
     2433                        $q['orderby'] = addslashes_gpc( $q['orderby'] );
    24132434
    24142435                        $orderby_array = array();
    24152436                        foreach ( explode( ' ', $q['orderby'] ) as $i => $orderby ) {