Make WordPress Core


Ignore:
Timestamp:
10/12/2023 02:34:12 PM (3 years ago)
Author:
davidbaumwald
Message:

Grouped backports to the 4.5 branch.

  • Comments: Prevent users who can not see a post from seeing comments on it.
  • Shortcodes: Restrict media shortcode ajax to certain type.
  • REST API: Ensure no-cache headers are sent when methods are overridden.
  • Prevent unintended behavior when certain objects are unserialized.

Merges [56834], [56835], [56836], and [56838] to the 4.5 branch.
Props xknown, jorbin, joehoyle, timothyblynjacobs, peterwilsoncc, ehtis, tykoted, antpb, rmccue.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.5/src/wp-admin/includes/ajax-actions.php

    r55780 r56857  
    29882988        $shortcode = wp_unslash( $_POST['shortcode'] );
    29892989
     2990        // Only process previews for media related shortcodes:
     2991        $found_shortcodes = get_shortcode_tags_in_content( $shortcode );
     2992        $media_shortcodes = array(
     2993                'audio',
     2994                'embed',
     2995                'playlist',
     2996                'video',
     2997                'gallery',
     2998        );
     2999
     3000        $other_shortcodes = array_diff( $found_shortcodes, $media_shortcodes );
     3001
     3002        if ( ! empty( $other_shortcodes ) ) {
     3003                wp_send_json_error();
     3004        }
     3005
    29903006        if ( ! empty( $_POST['post_ID'] ) ) {
    29913007                $post = get_post( (int) $_POST['post_ID'] );
    … …  
    29943010        // the embed shortcode requires a post
    29953011        if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
    2996                 if ( 'embed' === $shortcode ) {
     3012                if ( in_array( 'embed', $found_shortcodes, true ) ) {
    29973013                        wp_send_json_error();
    29983014                }
Note: See TracChangeset for help on using the changeset viewer.