Make WordPress Core


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

Grouped backports to the 4.3 branch.

  • Comments: Prevent users who can not see a post from seeing comments on it.
  • Shortcodes: Restrict ajax handler for media shortcode.
  • Prevent unintended behavior when certain objects are unserialized.

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

File:
1 edited

Legend:

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

    r55776 r56852  
    28702870    $shortcode = wp_unslash( $_POST['shortcode'] );
    28712871
     2872    // Only process previews for media related shortcodes:
     2873    $found_shortcodes = get_shortcode_tags_in_content( $shortcode );
     2874    $media_shortcodes = array(
     2875        'audio',
     2876        'embed',
     2877        'playlist',
     2878        'video',
     2879        'gallery',
     2880    );
     2881
     2882    $other_shortcodes = array_diff( $found_shortcodes, $media_shortcodes );
     2883
     2884    if ( ! empty( $other_shortcodes ) ) {
     2885        wp_send_json_error();
     2886    }
     2887
    28722888    if ( ! empty( $_POST['post_ID'] ) ) {
    28732889        $post = get_post( (int) $_POST['post_ID'] );
     
    28762892    // the embed shortcode requires a post
    28772893    if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
    2878         if ( 'embed' === $shortcode ) {
     2894        if ( in_array( 'embed', $found_shortcodes, true ) ) {
    28792895            wp_send_json_error();
    28802896        }
Note: See TracChangeset for help on using the changeset viewer.