Plugin Directory

Changeset 3495827


Ignore:
Timestamp:
03/31/2026 04:26:18 PM (5 days ago)
Author:
edge22
Message:

Update to version 2.2.1 from GitHub

Location:
generateblocks
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • generateblocks/tags/2.2.1/includes/class-meta-handler.php

    r3415721 r3495827  
    267267
    268268            if ( 'get_post_meta' === $callable ) {
     269                if ( is_numeric( $id ) && ! current_user_can( 'read_post', (int) $id ) ) {
     270                    return '';
     271                }
     272
    269273                if ( is_protected_meta( $key, 'post' ) ) {
    270274                    return '';
     
    474478        }
    475479
     480        // Require list_users capability to access other users' meta.
     481        if ( $id !== $current_id && ! current_user_can( 'list_users' ) ) {
     482            return rest_ensure_response(
     483                new WP_Error(
     484                    'rest_forbidden',
     485                    __( 'Sorry, you are not allowed to access this user\'s meta.', 'generateblocks' ),
     486                    array( 'status' => rest_authorization_required_code() )
     487                )
     488            );
     489        }
     490
    476491        $key         = $request->get_param( 'key' );
    477492        $single_only = true;
  • generateblocks/tags/2.2.1/includes/class-query-utils.php

    r3415721 r3495827  
    6868        $args = $request->get_param( 'args' ) ?? [];
    6969
     70        // Sanitize dangerous query args for users without list_users capability.
     71        if ( ! current_user_can( 'list_users' ) ) {
     72            unset( $args['meta_query'] );
     73            unset( $args['meta_key'] );
     74            unset( $args['meta_value'] );
     75            unset( $args['meta_compare'] );
     76        }
     77
    7078        if ( ! isset( $args['number'] ) ) {
    7179            $args['number'] = 150;
     
    8795                    unset( $user->data->user_login );
    8896                    unset( $user->data->user_email );
     97
     98                    // Remove capability data to prevent role enumeration.
     99                    unset( $user->caps );
     100                    unset( $user->allcaps );
    89101                }
    90102
  • generateblocks/tags/2.2.1/includes/dynamic-tags/class-dynamic-tag-callbacks.php

    r3415721 r3495827  
    6363                break;
    6464            case 'author_email':
     65                if ( defined( 'REST_REQUEST' ) && REST_REQUEST && ! current_user_can( 'list_users' ) ) {
     66                    break;
     67                }
     68
    6569                $user_id = get_post_field( 'post_author', $id );
    6670                $url     = 'mailto:' . get_the_author_meta( 'user_email', $user_id );
  • generateblocks/tags/2.2.1/includes/dynamic-tags/class-dynamic-tags.php

    r3415721 r3495827  
    503503        $context      = $request->get_param( 'context' );
    504504        $client_id    = $request->get_param( 'clientId' );
    505         $post_id      = $context['postId'] ?? 0;
     505        $post_id      = absint( $context['postId'] ?? 0 );
     506
     507        // Verify the current user can read the context post.
     508        if ( $post_id && ! current_user_can( 'read_post', $post_id ) ) {
     509            return rest_ensure_response( [] );
     510        }
     511
    506512        $fallback_id  = $post_id;
    507513        $instance     = new stdClass();
     
    513519        // Create a unique cache key.
    514520        $cache_key = sprintf(
    515             'replacements_%s_%s_%s',
     521            'replacements_%s_%s_%s_%s',
    516522            md5( $content ),
    517523            $client_id,
    518             $post_id
    519         );
    520 
    521         $replacements_cache = wp_cache_get( $cache_key, 'generate_blocks_dynamic_tags' );
     524            $post_id,
     525            get_current_user_id()
     526        );
     527
     528        $replacements_cache = wp_cache_get( $cache_key, 'generateblocks_dynamic_tags' );
    522529
    523530        // Return the cache here if present.
     
    555562                if ( 'user' === $type ) {
    556563                    $fallback_id = get_current_user_id();
     564                }
     565
     566                // Check object-level access for tags where id: refers to a post ID.
     567                // Parse options using the same logic the callbacks use so the
     568                // authorised ID always matches the ID used for data retrieval.
     569                if ( in_array( $type, [ 'post', 'author', 'media' ], true ) ) {
     570                    $tag_options_string = isset( $split_tag[1] ) ? ltrim( $split_tag[1], ' ' ) : '';
     571                    $tag_options        = GenerateBlocks_Register_Dynamic_Tag::parse_options( $tag_options_string, $tag_name );
     572                    $tag_post_id        = isset( $tag_options['id'] ) ? absint( $tag_options['id'] ) : 0;
     573
     574                    if ( $tag_post_id && ! current_user_can( 'read_post', $tag_post_id ) ) {
     575                        $replacements[] = [
     576                            'original'    => "{{{$tag}}}",
     577                            'replacement' => '',
     578                            'fallback'    => $fallback,
     579                        ];
     580
     581                        continue;
     582                    }
    557583                }
    558584
  • generateblocks/tags/2.2.1/package.json

    r3415721 r3495827  
    11{
    22    "name": "generateblocks",
    3     "version": "2.2.0",
     3    "version": "2.2.1",
    44    "private": true,
    55    "description": "A small collection of lightweight WordPress blocks that can accomplish nearly anything.",
  • generateblocks/tags/2.2.1/plugin.php

    r3415721 r3495827  
    66 * Author: Tom Usborne
    77 * Author URI: https://tomusborne.com
    8  * Version: 2.2.0
     8 * Version: 2.2.1
    99 * Requires at least: 6.5
    1010 * Requires PHP: 7.2
     
    2020}
    2121
    22 define( 'GENERATEBLOCKS_VERSION', '2.2.0' );
     22define( 'GENERATEBLOCKS_VERSION', '2.2.1' );
    2323define( 'GENERATEBLOCKS_DIR', plugin_dir_path( __FILE__ ) );
    2424define( 'GENERATEBLOCKS_DIR_URL', plugin_dir_url( __FILE__ ) );
  • generateblocks/tags/2.2.1/readme.txt

    r3415721 r3495827  
    66Tested up to: 6.9
    77Requires PHP: 7.2
    8 Stable tag: 2.2.0
     8Stable tag: 2.2.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    128128
    129129== Changelog ==
     130
     131= 2.2.1 =
     132* Security: Improve dynamic tag replacement security in the editor
    130133
    131134= 2.2.0 =
  • generateblocks/trunk/includes/class-meta-handler.php

    r3415721 r3495827  
    267267
    268268            if ( 'get_post_meta' === $callable ) {
     269                if ( is_numeric( $id ) && ! current_user_can( 'read_post', (int) $id ) ) {
     270                    return '';
     271                }
     272
    269273                if ( is_protected_meta( $key, 'post' ) ) {
    270274                    return '';
     
    474478        }
    475479
     480        // Require list_users capability to access other users' meta.
     481        if ( $id !== $current_id && ! current_user_can( 'list_users' ) ) {
     482            return rest_ensure_response(
     483                new WP_Error(
     484                    'rest_forbidden',
     485                    __( 'Sorry, you are not allowed to access this user\'s meta.', 'generateblocks' ),
     486                    array( 'status' => rest_authorization_required_code() )
     487                )
     488            );
     489        }
     490
    476491        $key         = $request->get_param( 'key' );
    477492        $single_only = true;
  • generateblocks/trunk/includes/class-query-utils.php

    r3415721 r3495827  
    6868        $args = $request->get_param( 'args' ) ?? [];
    6969
     70        // Sanitize dangerous query args for users without list_users capability.
     71        if ( ! current_user_can( 'list_users' ) ) {
     72            unset( $args['meta_query'] );
     73            unset( $args['meta_key'] );
     74            unset( $args['meta_value'] );
     75            unset( $args['meta_compare'] );
     76        }
     77
    7078        if ( ! isset( $args['number'] ) ) {
    7179            $args['number'] = 150;
     
    8795                    unset( $user->data->user_login );
    8896                    unset( $user->data->user_email );
     97
     98                    // Remove capability data to prevent role enumeration.
     99                    unset( $user->caps );
     100                    unset( $user->allcaps );
    89101                }
    90102
  • generateblocks/trunk/includes/dynamic-tags/class-dynamic-tag-callbacks.php

    r3415721 r3495827  
    6363                break;
    6464            case 'author_email':
     65                if ( defined( 'REST_REQUEST' ) && REST_REQUEST && ! current_user_can( 'list_users' ) ) {
     66                    break;
     67                }
     68
    6569                $user_id = get_post_field( 'post_author', $id );
    6670                $url     = 'mailto:' . get_the_author_meta( 'user_email', $user_id );
  • generateblocks/trunk/includes/dynamic-tags/class-dynamic-tags.php

    r3415721 r3495827  
    503503        $context      = $request->get_param( 'context' );
    504504        $client_id    = $request->get_param( 'clientId' );
    505         $post_id      = $context['postId'] ?? 0;
     505        $post_id      = absint( $context['postId'] ?? 0 );
     506
     507        // Verify the current user can read the context post.
     508        if ( $post_id && ! current_user_can( 'read_post', $post_id ) ) {
     509            return rest_ensure_response( [] );
     510        }
     511
    506512        $fallback_id  = $post_id;
    507513        $instance     = new stdClass();
     
    513519        // Create a unique cache key.
    514520        $cache_key = sprintf(
    515             'replacements_%s_%s_%s',
     521            'replacements_%s_%s_%s_%s',
    516522            md5( $content ),
    517523            $client_id,
    518             $post_id
    519         );
    520 
    521         $replacements_cache = wp_cache_get( $cache_key, 'generate_blocks_dynamic_tags' );
     524            $post_id,
     525            get_current_user_id()
     526        );
     527
     528        $replacements_cache = wp_cache_get( $cache_key, 'generateblocks_dynamic_tags' );
    522529
    523530        // Return the cache here if present.
     
    555562                if ( 'user' === $type ) {
    556563                    $fallback_id = get_current_user_id();
     564                }
     565
     566                // Check object-level access for tags where id: refers to a post ID.
     567                // Parse options using the same logic the callbacks use so the
     568                // authorised ID always matches the ID used for data retrieval.
     569                if ( in_array( $type, [ 'post', 'author', 'media' ], true ) ) {
     570                    $tag_options_string = isset( $split_tag[1] ) ? ltrim( $split_tag[1], ' ' ) : '';
     571                    $tag_options        = GenerateBlocks_Register_Dynamic_Tag::parse_options( $tag_options_string, $tag_name );
     572                    $tag_post_id        = isset( $tag_options['id'] ) ? absint( $tag_options['id'] ) : 0;
     573
     574                    if ( $tag_post_id && ! current_user_can( 'read_post', $tag_post_id ) ) {
     575                        $replacements[] = [
     576                            'original'    => "{{{$tag}}}",
     577                            'replacement' => '',
     578                            'fallback'    => $fallback,
     579                        ];
     580
     581                        continue;
     582                    }
    557583                }
    558584
  • generateblocks/trunk/package.json

    r3415721 r3495827  
    11{
    22    "name": "generateblocks",
    3     "version": "2.2.0",
     3    "version": "2.2.1",
    44    "private": true,
    55    "description": "A small collection of lightweight WordPress blocks that can accomplish nearly anything.",
  • generateblocks/trunk/plugin.php

    r3415721 r3495827  
    66 * Author: Tom Usborne
    77 * Author URI: https://tomusborne.com
    8  * Version: 2.2.0
     8 * Version: 2.2.1
    99 * Requires at least: 6.5
    1010 * Requires PHP: 7.2
     
    2020}
    2121
    22 define( 'GENERATEBLOCKS_VERSION', '2.2.0' );
     22define( 'GENERATEBLOCKS_VERSION', '2.2.1' );
    2323define( 'GENERATEBLOCKS_DIR', plugin_dir_path( __FILE__ ) );
    2424define( 'GENERATEBLOCKS_DIR_URL', plugin_dir_url( __FILE__ ) );
  • generateblocks/trunk/readme.txt

    r3415721 r3495827  
    66Tested up to: 6.9
    77Requires PHP: 7.2
    8 Stable tag: 2.2.0
     8Stable tag: 2.2.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    128128
    129129== Changelog ==
     130
     131= 2.2.1 =
     132* Security: Improve dynamic tag replacement security in the editor
    130133
    131134= 2.2.0 =
Note: See TracChangeset for help on using the changeset viewer.