Make WordPress Core

Changeset 64175


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

Security: Backport the WordPress 7.1.3 security fixes to the 5.5 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 5.5 branch.

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

Location:
branches/5.5
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/src/js/_enqueues/admin/common.js

    r48925 r64175  
    672672        link.parent('li').addClass('active');
    673673
    674         panel = $( link.attr('href') );
     674        panel = $( document ).find( link.attr('href') );
    675675
    676676        // Panels.
  • branches/5.5/src/wp-includes/class-http.php

    r48630 r64175  
    994994                        // Strip all /path/../ out of the path.
    995995                        while ( strpos( $path, '../' ) > 1 ) {
    996                                 $path = preg_replace( '![^/]+/\.\./!', '', $path );
     996                                $path = preg_replace( '![^/]+/\.\./!', '', $path, -1, $segment_replacement_count );
     997                                if ( 0 === $segment_replacement_count ) {
     998                                        break;
     999                                }
    9971000                        }
    9981001
  • branches/5.5/src/wp-includes/class-wp-oembed.php

    r49361 r64175  
    7474                        '#https?://(.+?\.)?slideshare\.net/.*#i'       => array( 'https://www.slideshare.net/api/oembed/2', true ),
    7575                        '#https?://(open|play)\.spotify\.com/.*#i'     => array( 'https://embed.spotify.com/oembed/', true ),
    76                         '#https?://(.+\.)?imgur\.com/.*#i'             => array( 'https://api.imgur.com/oembed', true ),
    7776                        '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i'    => array( 'https://api.meetup.com/oembed', true ),
    7877                        '#https?://(www\.)?issuu\.com/.+/docs/.+#i'    => array( 'https://issuu.com/oembed_wp', true ),
    … …  
    145144                 * | Flickr       | flic.kr                                   | 3.6.0   |
    146145                 * | Spotify      | spotify.com                               | 3.6.0   |
    147                  * | Imgur        | imgur.com                                 | 3.9.0   |
    148146                 * | Meetup.com   | meetup.com                                | 3.9.0   |
    149147                 * | Meetup.com   | meetu.ps                                  | 3.9.0   |
    … …  
    201199                 * | Instagram TV | instagr.am           | 5.1.0     | 5.5.2     |
    202200                 * | Facebook     | facebook.com         | 4.7.0     | 5.5.2     |
     201                 * | Imgur        | imgur.com            | 3.9.0     | 7.1.3     |
    203202                 *
    204203                 * @see wp_oembed_add_provider()
  • branches/5.5/src/wp-includes/class-wp-query.php

    r54556 r64175  
    30723072                }
    30733073
    3074                 if ( ! empty( $this->posts ) && $this->is_comment_feed && $this->is_singular ) {
    3075                         /** This filter is documented in wp-includes/query.php */
    3076                         $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
    3077 
    3078                         /** This filter is documented in wp-includes/query.php */
    3079                         $cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
    3080 
    3081                         /** This filter is documented in wp-includes/query.php */
    3082                         $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
    3083                         $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
    3084 
    3085                         /** This filter is documented in wp-includes/query.php */
    3086                         $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
    3087                         $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
    3088 
    3089                         /** This filter is documented in wp-includes/query.php */
    3090                         $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
    3091 
    3092                         $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
    3093                         $comments         = $wpdb->get_results( $comments_request );
    3094                         // Convert to WP_Comment.
    3095                         $this->comments      = array_map( 'get_comment', $comments );
    3096                         $this->comment_count = count( $this->comments );
    3097                 }
    3098 
    30993074                // Check post status to determine if post should be displayed.
    31003075                if ( ! empty( $this->posts ) && ( $this->is_single || $this->is_page ) ) {
    … …  
    31553130                }
    31563131
     3132                if ( ! empty( $this->posts ) && $this->is_comment_feed && $this->is_singular ) {
     3133                        /** This filter is documented in wp-includes/query.php */
     3134                        $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
     3135
     3136                        /** This filter is documented in wp-includes/query.php */
     3137                        $cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
     3138
     3139                        /** This filter is documented in wp-includes/query.php */
     3140                        $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
     3141                        $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
     3142
     3143                        /** This filter is documented in wp-includes/query.php */
     3144                        $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
     3145                        $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
     3146
     3147                        /** This filter is documented in wp-includes/query.php */
     3148                        $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
     3149
     3150                        $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
     3151                        $comments         = $wpdb->get_results( $comments_request );
     3152                        // Convert to WP_Comment.
     3153                        $this->comments      = array_map( 'get_comment', $comments );
     3154                        $this->comment_count = count( $this->comments );
     3155                }
     3156
    31573157                // Put sticky posts at the top of the posts array.
    31583158                $sticky_posts = get_option( 'sticky_posts' );
  • branches/5.5/src/wp-includes/post.php

    r54556 r64175  
    49074907        do_action( 'transition_post_status', $new_status, $old_status, $post );
    49084908
    4909         /**
    4910          * Fires when a post is transitioned from one status to another.
    4911          *
    4912          * The dynamic portions of the hook name, `$new_status` and `$old status`,
    4913          * refer to the old and new post statuses, respectively.
    4914          *
    4915          * @since 2.3.0
    4916          *
    4917          * @param WP_Post $post Post object.
    4918          */
    4919         do_action( "{$old_status}_to_{$new_status}", $post );
    4920 
    4921         /**
    4922          * Fires when a post is transitioned from one status to another.
    4923          *
    4924          * The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
    4925          * refer to the new post status and post type, respectively.
    4926          *
    4927          * Please note: When this action is hooked using a particular post status (like
    4928          * 'publish', as `publish_{$post->post_type}`), it will fire both when a post is
    4929          * first transitioned to that status from something else, as well as upon
    4930          * subsequent post updates (old and new status are both the same).
    4931          *
    4932          * Therefore, if you are looking to only fire a callback when a post is first
    4933          * transitioned to a status, use the {@see 'transition_post_status'} hook instead.
    4934          *
    4935          * @since 2.3.0
    4936          *
    4937          * @param int     $post_id Post ID.
    4938          * @param WP_Post $post    Post object.
    4939          */
    4940         do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
     4909        $new_status_object = get_post_status_object( $new_status );
     4910        $old_status_valid  = get_post_status_object( $old_status ) || 'new' === $old_status;
     4911        $post_type_object  = get_post_type_object( $post->post_type );
     4912
     4913        if ( $new_status_object && $old_status_valid ) {
     4914                /**
     4915                 * Fires when a post is transitioned from one status to another.
     4916                 *
     4917                 * The dynamic portions of the hook name, `$new_status` and `$old status`,
     4918                 * refer to the old and new post statuses, respectively.
     4919                 *
     4920                 * @since 2.3.0
     4921                 *
     4922                 * @param WP_Post $post Post object.
     4923                 */
     4924                do_action( "{$old_status}_to_{$new_status}", $post );
     4925        }
     4926
     4927        if ( $new_status_object && $post_type_object ) {
     4928                /**
     4929                 * Fires when a post is transitioned from one status to another.
     4930                 *
     4931                 * The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
     4932                 * refer to the new post status and post type, respectively.
     4933                 *
     4934                 * Please note: When this action is hooked using a particular post status (like
     4935                 * 'publish', as `publish_{$post->post_type}`), it will fire both when a post is
     4936                 * first transitioned to that status from something else, as well as upon
     4937                 * subsequent post updates (old and new status are both the same).
     4938                 *
     4939                 * Therefore, if you are looking to only fire a callback when a post is first
     4940                 * transitioned to a status, use the {@see 'transition_post_status'} hook instead.
     4941                 *
     4942                 * @since 2.3.0
     4943                 *
     4944                 * @param int     $post_id Post ID.
     4945                 * @param WP_Post $post    Post object.
     4946                 */
     4947                do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
     4948        }
    49414949}
    49424950
  • branches/5.5/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r60831 r64175  
    592592                }
    593593
    594                 if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) && ! current_user_can( $post_type->cap->publish_posts ) ) {
     594                if ( ! empty( $request['sticky'] ) && ( ! current_user_can( $post_type->cap->edit_others_posts ) || ! current_user_can( $post_type->cap->publish_posts ) ) ) {
    595595                        return new WP_Error(
    596596                                'rest_cannot_assign_sticky',
    … …  
    771771                }
    772772
    773                 if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) && ! current_user_can( $post_type->cap->publish_posts ) ) {
     773                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 ) ) ) {
    774774                        return new WP_Error(
    775775                                'rest_cannot_assign_sticky',
Note: See TracChangeset for help on using the changeset viewer.