Make WordPress Core

Changeset 64182


Ignore:
Timestamp:
10/06/2026 05:43:22 PM (5 weeks ago)
Author:
johnbillion
Message:

Security: Backport the WordPress 7.1.3 security fixes to the 4.8 branch.

  • REST API: Require both capabilities to change a post's sticky status.
  • Query: Prevent exposure of comments on unviewable posts.
  • Posts, Post Types: Fire dynamic status transition hooks only for registered statuses and post types.
  • Administration: Treat contextual help tab links as selectors.
  • Embeds: Remove support for Imgur oEmbeds.
  • HTTP: Improve relative path resolution in WP_Http::make_absolute_url().

Merges r64127, r64128, r64130, r64131, r64132, r64133 to the 4.8 branch.

Props xknown, jeremyfelt, jorbin, peterwilsoncc, ehtis, westonruter, lancewillett, jonsurrell, marcs0h, rfaile313, johnbillion, vortfu.

Location:
branches/4.8
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

  • branches/4.8/src/wp-admin/js/common.js

    r40648 r64182  
    169169        link.parent('li').addClass('active');
    170170
    171         panel = $( link.attr('href') );
     171        panel = $( document ).find( link.attr('href') );
    172172
    173173        // Panels
  • branches/4.8/src/wp-includes/class-http.php

    r40689 r64182  
    945945                        // Strip all /path/../ out of the path.
    946946                        while ( strpos( $path, '../' ) > 1 ) {
    947                                 $path = preg_replace( '![^/]+/\.\./!', '', $path );
     947                                $path = preg_replace( '![^/]+/\.\./!', '', $path, -1, $segment_replacement_count );
     948                                if ( 0 === $segment_replacement_count ) {
     949                                        break;
     950                                }
    948951                        }
    949952
  • branches/4.8/src/wp-includes/class-oembed.php

    r41025 r64182  
    8484                        '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i'           => array( 'https://api.instagram.com/oembed',                          true  ),
    8585                        '#https?://(open|play)\.spotify\.com/.*#i'                 => array( 'https://embed.spotify.com/oembed/',                         true  ),
    86                         '#https?://(.+\.)?imgur\.com/.*#i'                         => array( 'http://api.imgur.com/oembed',                               true  ),
    8786                        '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i'                => array( 'https://api.meetup.com/oembed',                             true  ),
    8887                        '#https?://(www\.)?issuu\.com/.+/docs/.+#i'                => array( 'https://issuu.com/oembed_wp',                               true  ),
    … …  
    157156                 * | Flickr       | flic.kr               |      Yes       | 3.6.0     |
    158157                 * | Spotify      | spotify.com           |      Yes       | 3.6.0     |
    159                  * | Imgur        | imgur.com             |      Yes       | 3.9.0     |
    160158                 * | Meetup.com   | meetup.com            |      Yes       | 3.9.0     |
    161159                 * | Meetup.com   | meetu.ps              |      Yes       | 3.9.0     |
    … …  
    195193                 * | Rdio         | rdio.com             |      Yes       | 3.6.0     | 4.4.1     |
    196194                 * | Rdio         | rd.io                |      Yes       | 3.6.0     | 4.4.1     |
     195                 * | Imgur        | imgur.com            |      Yes       | 3.9.0     | 7.1.3     |
    197196                 *
    198197                 * @see wp_oembed_add_provider()
  • branches/4.8/src/wp-includes/class-wp-query.php

    r54568 r64182  
    28972897                }
    28982898
    2899                 if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
    2900                         /** This filter is documented in wp-includes/query.php */
    2901                         $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
    2902 
    2903                         /** This filter is documented in wp-includes/query.php */
    2904                         $cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
    2905 
    2906                         /** This filter is documented in wp-includes/query.php */
    2907                         $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
    2908                         $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
    2909 
    2910                         /** This filter is documented in wp-includes/query.php */
    2911                         $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
    2912                         $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
    2913 
    2914                         /** This filter is documented in wp-includes/query.php */
    2915                         $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) );
    2916 
    2917                         $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
    2918                         $comments = $wpdb->get_results($comments_request);
    2919                         // Convert to WP_Comment
    2920                         $this->comments = array_map( 'get_comment', $comments );
    2921                         $this->comment_count = count($this->comments);
    2922                 }
    2923 
    29242899                // Check post status to determine if post should be displayed.
    29252900                if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) {
    … …  
    29702945                }
    29712946
     2947                if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
     2948                        /** This filter is documented in wp-includes/query.php */
     2949                        $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
     2950
     2951                        /** This filter is documented in wp-includes/query.php */
     2952                        $cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
     2953
     2954                        /** This filter is documented in wp-includes/query.php */
     2955                        $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
     2956                        $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
     2957
     2958                        /** This filter is documented in wp-includes/query.php */
     2959                        $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
     2960                        $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
     2961
     2962                        /** This filter is documented in wp-includes/query.php */
     2963                        $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) );
     2964
     2965                        $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
     2966                        $comments = $wpdb->get_results($comments_request);
     2967                        // Convert to WP_Comment
     2968                        $this->comments = array_map( 'get_comment', $comments );
     2969                        $this->comment_count = count($this->comments);
     2970                }
     2971
    29722972                // Put sticky posts at the top of the posts array
    29732973                $sticky_posts = get_option('sticky_posts');
  • branches/4.8/src/wp-includes/post.php

    r54568 r64182  
    40664066        do_action( 'transition_post_status', $new_status, $old_status, $post );
    40674067
    4068         /**
    4069          * Fires when a post is transitioned from one status to another.
    4070          *
    4071          * The dynamic portions of the hook name, `$new_status` and `$old status`,
    4072          * refer to the old and new post statuses, respectively.
    4073          *
    4074          * @since 2.3.0
    4075          *
    4076          * @param WP_Post $post Post object.
    4077          */
    4078         do_action( "{$old_status}_to_{$new_status}", $post );
    4079 
    4080         /**
    4081          * Fires when a post is transitioned from one status to another.
    4082          *
    4083          * The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
    4084          * refer to the new post status and post type, respectively.
    4085          *
    4086          * Please note: When this action is hooked using a particular post status (like
    4087          * 'publish', as `publish_{$post->post_type}`), it will fire both when a post is
    4088          * first transitioned to that status from something else, as well as upon
    4089          * subsequent post updates (old and new status are both the same).
    4090          *
    4091          * Therefore, if you are looking to only fire a callback when a post is first
    4092          * transitioned to a status, use the {@see 'transition_post_status'} hook instead.
    4093          *
    4094          * @since 2.3.0
    4095          *
    4096          * @param int     $post_id Post ID.
    4097          * @param WP_Post $post    Post object.
    4098          */
    4099         do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
     4068        $new_status_object = get_post_status_object( $new_status );
     4069        $old_status_valid  = get_post_status_object( $old_status ) || 'new' === $old_status;
     4070        $post_type_object  = get_post_type_object( $post->post_type );
     4071
     4072        if ( $new_status_object && $old_status_valid ) {
     4073                /**
     4074                 * Fires when a post is transitioned from one status to another.
     4075                 *
     4076                 * The dynamic portions of the hook name, `$new_status` and `$old status`,
     4077                 * refer to the old and new post statuses, respectively.
     4078                 *
     4079                 * @since 2.3.0
     4080                 *
     4081                 * @param WP_Post $post Post object.
     4082                 */
     4083                do_action( "{$old_status}_to_{$new_status}", $post );
     4084        }
     4085
     4086        if ( $new_status_object && $post_type_object ) {
     4087                /**
     4088                 * Fires when a post is transitioned from one status to another.
     4089                 *
     4090                 * The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
     4091                 * refer to the new post status and post type, respectively.
     4092                 *
     4093                 * Please note: When this action is hooked using a particular post status (like
     4094                 * 'publish', as `publish_{$post->post_type}`), it will fire both when a post is
     4095                 * first transitioned to that status from something else, as well as upon
     4096                 * subsequent post updates (old and new status are both the same).
     4097                 *
     4098                 * Therefore, if you are looking to only fire a callback when a post is first
     4099                 * transitioned to a status, use the {@see 'transition_post_status'} hook instead.
     4100                 *
     4101                 * @since 2.3.0
     4102                 *
     4103                 * @param int     $post_id Post ID.
     4104                 * @param WP_Post $post    Post object.
     4105                 */
     4106                do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
     4107        }
    41004108}
    41014109
  • branches/4.8/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r60838 r64182  
    554554                }
    555555
    556                 if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) && ! current_user_can( $post_type->cap->publish_posts ) ) {
     556                if ( ! empty( $request['sticky'] ) && ( ! current_user_can( $post_type->cap->edit_others_posts ) || ! current_user_can( $post_type->cap->publish_posts ) ) ) {
    557557                        return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
    558558                }
    … …  
    698698                }
    699699
    700                 if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) && ! current_user_can( $post_type->cap->publish_posts ) ) {
     700                if ( isset( $request['sticky'] ) && is_sticky( $post->ID ) !== (bool) $request['sticky'] && ( ! current_user_can( $post_type->cap->edit_others_posts ) || ! current_user_can( $post_type->cap->publish_posts ) ) ) {
    701701                        return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
    702702                }
Note: See TracChangeset for help on using the changeset viewer.