Make WordPress Core

Changeset 64176


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

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

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

Location:
branches/5.4
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/5.4

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

    r47122 r64176  
    339339        link.parent('li').addClass('active');
    340340
    341         panel = $( link.attr('href') );
     341        panel = $( document ).find( link.attr('href') );
    342342
    343343        // Panels.
  • branches/5.4/src/wp-includes/class-http.php

    r47346 r64176  
    989989                        // Strip all /path/../ out of the path.
    990990                        while ( strpos( $path, '../' ) > 1 ) {
    991                                 $path = preg_replace( '![^/]+/\.\./!', '', $path );
     991                                $path = preg_replace( '![^/]+/\.\./!', '', $path, -1, $segment_replacement_count );
     992                                if ( 0 === $segment_replacement_count ) {
     993                                        break;
     994                                }
    992995                        }
    993996
  • branches/5.4/src/wp-includes/class-wp-oembed.php

    r47216 r64176  
    7676                        '#https?://(www\.)?instagr(\.am|am\.com)/(p|tv)/.*#i' => array( 'https://api.instagram.com/oembed', true ),
    7777                        '#https?://(open|play)\.spotify\.com/.*#i'     => array( 'https://embed.spotify.com/oembed/', true ),
    78                         '#https?://(.+\.)?imgur\.com/.*#i'             => array( 'https://api.imgur.com/oembed', true ),
    7978                        '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i'    => array( 'https://api.meetup.com/oembed', true ),
    8079                        '#https?://(www\.)?issuu\.com/.+/docs/.+#i'    => array( 'https://issuu.com/oembed_wp', true ),
    … …  
    160159                 * | Flickr       | flic.kr                                   | 3.6.0   |
    161160                 * | Spotify      | spotify.com                               | 3.6.0   |
    162                  * | Imgur        | imgur.com                                 | 3.9.0   |
    163161                 * | Meetup.com   | meetup.com                                | 3.9.0   |
    164162                 * | Meetup.com   | meetu.ps                                  | 3.9.0   |
    … …  
    213211                 * | Funny or Die | funnyordie.com       | 3.0.0     | 5.1.0     |
    214212                 * | CollegeHumor | collegehumor.com     | 4.0.0     | 5.3.1     |
     213                 * | Imgur        | imgur.com            | 3.9.0     | 7.1.3     |
    215214                 *
    216215                 * @see wp_oembed_add_provider()
  • branches/5.4/src/wp-includes/class-wp-query.php

    r54559 r64176  
    30613061                }
    30623062
    3063                 if ( ! empty( $this->posts ) && $this->is_comment_feed && $this->is_singular ) {
    3064                         /** This filter is documented in wp-includes/query.php */
    3065                         $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
    3066 
    3067                         /** This filter is documented in wp-includes/query.php */
    3068                         $cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
    3069 
    3070                         /** This filter is documented in wp-includes/query.php */
    3071                         $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
    3072                         $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
    3073 
    3074                         /** This filter is documented in wp-includes/query.php */
    3075                         $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
    3076                         $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
    3077 
    3078                         /** This filter is documented in wp-includes/query.php */
    3079                         $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
    3080 
    3081                         $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
    3082                         $comments         = $wpdb->get_results( $comments_request );
    3083                         // Convert to WP_Comment.
    3084                         $this->comments      = array_map( 'get_comment', $comments );
    3085                         $this->comment_count = count( $this->comments );
    3086                 }
    3087 
    30883063                // Check post status to determine if post should be displayed.
    30893064                if ( ! empty( $this->posts ) && ( $this->is_single || $this->is_page ) ) {
    … …  
    31443119                }
    31453120
     3121                if ( ! empty( $this->posts ) && $this->is_comment_feed && $this->is_singular ) {
     3122                        /** This filter is documented in wp-includes/query.php */
     3123                        $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
     3124
     3125                        /** This filter is documented in wp-includes/query.php */
     3126                        $cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
     3127
     3128                        /** This filter is documented in wp-includes/query.php */
     3129                        $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
     3130                        $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
     3131
     3132                        /** This filter is documented in wp-includes/query.php */
     3133                        $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
     3134                        $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
     3135
     3136                        /** This filter is documented in wp-includes/query.php */
     3137                        $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
     3138
     3139                        $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
     3140                        $comments         = $wpdb->get_results( $comments_request );
     3141                        // Convert to WP_Comment.
     3142                        $this->comments      = array_map( 'get_comment', $comments );
     3143                        $this->comment_count = count( $this->comments );
     3144                }
     3145
    31463146                // Put sticky posts at the top of the posts array.
    31473147                $sticky_posts = get_option( 'sticky_posts' );
  • branches/5.4/src/wp-includes/post.php

    r54559 r64176  
    47614761        do_action( 'transition_post_status', $new_status, $old_status, $post );
    47624762
    4763         /**
    4764          * Fires when a post is transitioned from one status to another.
    4765          *
    4766          * The dynamic portions of the hook name, `$new_status` and `$old status`,
    4767          * refer to the old and new post statuses, respectively.
    4768          *
    4769          * @since 2.3.0
    4770          *
    4771          * @param WP_Post $post Post object.
    4772          */
    4773         do_action( "{$old_status}_to_{$new_status}", $post );
    4774 
    4775         /**
    4776          * Fires when a post is transitioned from one status to another.
    4777          *
    4778          * The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
    4779          * refer to the new post status and post type, respectively.
    4780          *
    4781          * Please note: When this action is hooked using a particular post status (like
    4782          * 'publish', as `publish_{$post->post_type}`), it will fire both when a post is
    4783          * first transitioned to that status from something else, as well as upon
    4784          * subsequent post updates (old and new status are both the same).
    4785          *
    4786          * Therefore, if you are looking to only fire a callback when a post is first
    4787          * transitioned to a status, use the {@see 'transition_post_status'} hook instead.
    4788          *
    4789          * @since 2.3.0
    4790          *
    4791          * @param int     $post_id Post ID.
    4792          * @param WP_Post $post    Post object.
    4793          */
    4794         do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
     4763        $new_status_object = get_post_status_object( $new_status );
     4764        $old_status_valid  = get_post_status_object( $old_status ) || 'new' === $old_status;
     4765        $post_type_object  = get_post_type_object( $post->post_type );
     4766
     4767        if ( $new_status_object && $old_status_valid ) {
     4768                /**
     4769                 * Fires when a post is transitioned from one status to another.
     4770                 *
     4771                 * The dynamic portions of the hook name, `$new_status` and `$old status`,
     4772                 * refer to the old and new post statuses, respectively.
     4773                 *
     4774                 * @since 2.3.0
     4775                 *
     4776                 * @param WP_Post $post Post object.
     4777                 */
     4778                do_action( "{$old_status}_to_{$new_status}", $post );
     4779        }
     4780
     4781        if ( $new_status_object && $post_type_object ) {
     4782                /**
     4783                 * Fires when a post is transitioned from one status to another.
     4784                 *
     4785                 * The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
     4786                 * refer to the new post status and post type, respectively.
     4787                 *
     4788                 * Please note: When this action is hooked using a particular post status (like
     4789                 * 'publish', as `publish_{$post->post_type}`), it will fire both when a post is
     4790                 * first transitioned to that status from something else, as well as upon
     4791                 * subsequent post updates (old and new status are both the same).
     4792                 *
     4793                 * Therefore, if you are looking to only fire a callback when a post is first
     4794                 * transitioned to a status, use the {@see 'transition_post_status'} hook instead.
     4795                 *
     4796                 * @since 2.3.0
     4797                 *
     4798                 * @param int     $post_id Post ID.
     4799                 * @param WP_Post $post    Post object.
     4800                 */
     4801                do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
     4802        }
    47954803}
    47964804
  • branches/5.4/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r60832 r64176  
    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.