Make WordPress Core


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

Grouped backports to the 4.4 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.4 branch.
Props xknown, jorbin, joehoyle, timothyblynjacobs, peterwilsoncc, ehtis, tykoted, antpb, rmccue.

File:
1 edited

Legend:

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

    r55779 r56855  
    29812981    $shortcode = wp_unslash( $_POST['shortcode'] );
    29822982
     2983    // Only process previews for media related shortcodes:
     2984    $found_shortcodes = get_shortcode_tags_in_content( $shortcode );
     2985    $media_shortcodes = array(
     2986        'audio',
     2987        'embed',
     2988        'playlist',
     2989        'video',
     2990        'gallery',
     2991    );
     2992
     2993    $other_shortcodes = array_diff( $found_shortcodes, $media_shortcodes );
     2994
     2995    if ( ! empty( $other_shortcodes ) ) {
     2996        wp_send_json_error();
     2997    }
     2998
    29832999    if ( ! empty( $_POST['post_ID'] ) ) {
    29843000        $post = get_post( (int) $_POST['post_ID'] );
     
    29873003    // the embed shortcode requires a post
    29883004    if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
    2989         if ( 'embed' === $shortcode ) {
     3005        if ( in_array( 'embed', $found_shortcodes, true ) ) {
    29903006            wp_send_json_error();
    29913007        }
Note: See TracChangeset for help on using the changeset viewer.