Make WordPress Core

Changeset 64177


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

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

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

Location:
branches/5.3
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/5.3

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

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

    r46468 r64177  
    975975                        // Strip all /path/../ out of the path.
    976976                        while ( strpos( $path, '../' ) > 1 ) {
    977                                 $path = preg_replace( '![^/]+/\.\./!', '', $path );
     977                                $path = preg_replace( '![^/]+/\.\./!', '', $path, -1, $segment_replacement_count );
     978                                if ( 0 === $segment_replacement_count ) {
     979                                        break;
     980                                }
    978981                        }
    979982
  • branches/5.3/src/wp-includes/class-wp-oembed.php

    r46768 r64177  
    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 ),
    … …  
    159158                 * | Flickr       | flic.kr                                   | 3.6.0   |
    160159                 * | Spotify      | spotify.com                               | 3.6.0   |
    161                  * | Imgur        | imgur.com                                 | 3.9.0   |
    162160                 * | Meetup.com   | meetup.com                                | 3.9.0   |
    163161                 * | Meetup.com   | meetu.ps                                  | 3.9.0   |
    … …  
    211209                 * | Funny or Die | funnyordie.com       | 3.0.0     | 5.1.0     |
    212210                 * | CollegeHumor | collegehumor.com     | 4.0.0     | 5.3.1     |
     211                 * | Imgur        | imgur.com            | 3.9.0     | 7.1.3     |
    213212                 *
    214213                 * @see wp_oembed_add_provider()
  • branches/5.3/src/wp-includes/class-wp-query.php

    r54562 r64177  
    30463046                }
    30473047
    3048                 if ( ! empty( $this->posts ) && $this->is_comment_feed && $this->is_singular ) {
    3049                         /** This filter is documented in wp-includes/query.php */
    3050                         $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
    3051 
    3052                         /** This filter is documented in wp-includes/query.php */
    3053                         $cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
    3054 
    3055                         /** This filter is documented in wp-includes/query.php */
    3056                         $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
    3057                         $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
    3058 
    3059                         /** This filter is documented in wp-includes/query.php */
    3060                         $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
    3061                         $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
    3062 
    3063                         /** This filter is documented in wp-includes/query.php */
    3064                         $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
    3065 
    3066                         $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
    3067                         $comments         = $wpdb->get_results( $comments_request );
    3068                         // Convert to WP_Comment
    3069                         $this->comments      = array_map( 'get_comment', $comments );
    3070                         $this->comment_count = count( $this->comments );
    3071                 }
    3072 
    30733048                // Check post status to determine if post should be displayed.
    30743049                if ( ! empty( $this->posts ) && ( $this->is_single || $this->is_page ) ) {
    … …  
    31213096                }
    31223097
     3098                if ( ! empty( $this->posts ) && $this->is_comment_feed && $this->is_singular ) {
     3099                        /** This filter is documented in wp-includes/query.php */
     3100                        $cjoin = apply_filters_ref_array( 'comment_feed_join', array( '', &$this ) );
     3101
     3102                        /** This filter is documented in wp-includes/query.php */
     3103                        $cwhere = apply_filters_ref_array( 'comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) );
     3104
     3105                        /** This filter is documented in wp-includes/query.php */
     3106                        $cgroupby = apply_filters_ref_array( 'comment_feed_groupby', array( '', &$this ) );
     3107                        $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
     3108
     3109                        /** This filter is documented in wp-includes/query.php */
     3110                        $corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
     3111                        $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
     3112
     3113                        /** This filter is documented in wp-includes/query.php */
     3114                        $climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
     3115
     3116                        $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
     3117                        $comments         = $wpdb->get_results( $comments_request );
     3118                        // Convert to WP_Comment
     3119                        $this->comments      = array_map( 'get_comment', $comments );
     3120                        $this->comment_count = count( $this->comments );
     3121                }
     3122
    31233123                // Put sticky posts at the top of the posts array
    31243124                $sticky_posts = get_option( 'sticky_posts' );
  • branches/5.3/src/wp-includes/post.php

    r54562 r64177  
    47234723        do_action( 'transition_post_status', $new_status, $old_status, $post );
    47244724
    4725         /**
    4726          * Fires when a post is transitioned from one status to another.
    4727          *
    4728          * The dynamic portions of the hook name, `$new_status` and `$old status`,
    4729          * refer to the old and new post statuses, respectively.
    4730          *
    4731          * @since 2.3.0
    4732          *
    4733          * @param WP_Post $post Post object.
    4734          */
    4735         do_action( "{$old_status}_to_{$new_status}", $post );
    4736 
    4737         /**
    4738          * Fires when a post is transitioned from one status to another.
    4739          *
    4740          * The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
    4741          * refer to the new post status and post type, respectively.
    4742          *
    4743          * Please note: When this action is hooked using a particular post status (like
    4744          * 'publish', as `publish_{$post->post_type}`), it will fire both when a post is
    4745          * first transitioned to that status from something else, as well as upon
    4746          * subsequent post updates (old and new status are both the same).
    4747          *
    4748          * Therefore, if you are looking to only fire a callback when a post is first
    4749          * transitioned to a status, use the {@see 'transition_post_status'} hook instead.
    4750          *
    4751          * @since 2.3.0
    4752          *
    4753          * @param int     $post_id Post ID.
    4754          * @param WP_Post $post    Post object.
    4755          */
    4756         do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
     4725        $new_status_object = get_post_status_object( $new_status );
     4726        $old_status_valid  = get_post_status_object( $old_status ) || 'new' === $old_status;
     4727        $post_type_object  = get_post_type_object( $post->post_type );
     4728
     4729        if ( $new_status_object && $old_status_valid ) {
     4730                /**
     4731                 * Fires when a post is transitioned from one status to another.
     4732                 *
     4733                 * The dynamic portions of the hook name, `$new_status` and `$old status`,
     4734                 * refer to the old and new post statuses, respectively.
     4735                 *
     4736                 * @since 2.3.0
     4737                 *
     4738                 * @param WP_Post $post Post object.
     4739                 */
     4740                do_action( "{$old_status}_to_{$new_status}", $post );
     4741        }
     4742
     4743        if ( $new_status_object && $post_type_object ) {
     4744                /**
     4745                 * Fires when a post is transitioned from one status to another.
     4746                 *
     4747                 * The dynamic portions of the hook name, `$new_status` and `$post->post_type`,
     4748                 * refer to the new post status and post type, respectively.
     4749                 *
     4750                 * Please note: When this action is hooked using a particular post status (like
     4751                 * 'publish', as `publish_{$post->post_type}`), it will fire both when a post is
     4752                 * first transitioned to that status from something else, as well as upon
     4753                 * subsequent post updates (old and new status are both the same).
     4754                 *
     4755                 * Therefore, if you are looking to only fire a callback when a post is first
     4756                 * transitioned to a status, use the {@see 'transition_post_status'} hook instead.
     4757                 *
     4758                 * @since 2.3.0
     4759                 *
     4760                 * @param int     $post_id Post ID.
     4761                 * @param WP_Post $post    Post object.
     4762                 */
     4763                do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
     4764        }
    47574765}
    47584766
  • branches/5.3/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r60833 r64177  
    551551                }
    552552
    553                 if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) && ! current_user_can( $post_type->cap->publish_posts ) ) {
     553                if ( ! empty( $request['sticky'] ) && ( ! current_user_can( $post_type->cap->edit_others_posts ) || ! current_user_can( $post_type->cap->publish_posts ) ) ) {
    554554                        return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
    555555                }
    … …  
    706706                }
    707707
    708                 if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) && ! current_user_can( $post_type->cap->publish_posts ) ) {
     708                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 ) ) ) {
    709709                        return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) );
    710710                }
Note: See TracChangeset for help on using the changeset viewer.