Changeset 3495827
- Timestamp:
- 03/31/2026 04:26:18 PM (5 days ago)
- Location:
- generateblocks
- Files:
-
- 14 edited
- 1 copied
-
tags/2.2.1 (copied) (copied from generateblocks/trunk)
-
tags/2.2.1/includes/class-meta-handler.php (modified) (2 diffs)
-
tags/2.2.1/includes/class-query-utils.php (modified) (2 diffs)
-
tags/2.2.1/includes/dynamic-tags/class-dynamic-tag-callbacks.php (modified) (1 diff)
-
tags/2.2.1/includes/dynamic-tags/class-dynamic-tags.php (modified) (3 diffs)
-
tags/2.2.1/package.json (modified) (1 diff)
-
tags/2.2.1/plugin.php (modified) (2 diffs)
-
tags/2.2.1/readme.txt (modified) (2 diffs)
-
trunk/includes/class-meta-handler.php (modified) (2 diffs)
-
trunk/includes/class-query-utils.php (modified) (2 diffs)
-
trunk/includes/dynamic-tags/class-dynamic-tag-callbacks.php (modified) (1 diff)
-
trunk/includes/dynamic-tags/class-dynamic-tags.php (modified) (3 diffs)
-
trunk/package.json (modified) (1 diff)
-
trunk/plugin.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
generateblocks/tags/2.2.1/includes/class-meta-handler.php
r3415721 r3495827 267 267 268 268 if ( 'get_post_meta' === $callable ) { 269 if ( is_numeric( $id ) && ! current_user_can( 'read_post', (int) $id ) ) { 270 return ''; 271 } 272 269 273 if ( is_protected_meta( $key, 'post' ) ) { 270 274 return ''; … … 474 478 } 475 479 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 476 491 $key = $request->get_param( 'key' ); 477 492 $single_only = true; -
generateblocks/tags/2.2.1/includes/class-query-utils.php
r3415721 r3495827 68 68 $args = $request->get_param( 'args' ) ?? []; 69 69 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 70 78 if ( ! isset( $args['number'] ) ) { 71 79 $args['number'] = 150; … … 87 95 unset( $user->data->user_login ); 88 96 unset( $user->data->user_email ); 97 98 // Remove capability data to prevent role enumeration. 99 unset( $user->caps ); 100 unset( $user->allcaps ); 89 101 } 90 102 -
generateblocks/tags/2.2.1/includes/dynamic-tags/class-dynamic-tag-callbacks.php
r3415721 r3495827 63 63 break; 64 64 case 'author_email': 65 if ( defined( 'REST_REQUEST' ) && REST_REQUEST && ! current_user_can( 'list_users' ) ) { 66 break; 67 } 68 65 69 $user_id = get_post_field( 'post_author', $id ); 66 70 $url = 'mailto:' . get_the_author_meta( 'user_email', $user_id ); -
generateblocks/tags/2.2.1/includes/dynamic-tags/class-dynamic-tags.php
r3415721 r3495827 503 503 $context = $request->get_param( 'context' ); 504 504 $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 506 512 $fallback_id = $post_id; 507 513 $instance = new stdClass(); … … 513 519 // Create a unique cache key. 514 520 $cache_key = sprintf( 515 'replacements_%s_%s_%s ',521 'replacements_%s_%s_%s_%s', 516 522 md5( $content ), 517 523 $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' ); 522 529 523 530 // Return the cache here if present. … … 555 562 if ( 'user' === $type ) { 556 563 $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 } 557 583 } 558 584 -
generateblocks/tags/2.2.1/package.json
r3415721 r3495827 1 1 { 2 2 "name": "generateblocks", 3 "version": "2.2. 0",3 "version": "2.2.1", 4 4 "private": true, 5 5 "description": "A small collection of lightweight WordPress blocks that can accomplish nearly anything.", -
generateblocks/tags/2.2.1/plugin.php
r3415721 r3495827 6 6 * Author: Tom Usborne 7 7 * Author URI: https://tomusborne.com 8 * Version: 2.2. 08 * Version: 2.2.1 9 9 * Requires at least: 6.5 10 10 * Requires PHP: 7.2 … … 20 20 } 21 21 22 define( 'GENERATEBLOCKS_VERSION', '2.2. 0' );22 define( 'GENERATEBLOCKS_VERSION', '2.2.1' ); 23 23 define( 'GENERATEBLOCKS_DIR', plugin_dir_path( __FILE__ ) ); 24 24 define( 'GENERATEBLOCKS_DIR_URL', plugin_dir_url( __FILE__ ) ); -
generateblocks/tags/2.2.1/readme.txt
r3415721 r3495827 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.2 8 Stable tag: 2.2. 08 Stable tag: 2.2.1 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 128 128 129 129 == Changelog == 130 131 = 2.2.1 = 132 * Security: Improve dynamic tag replacement security in the editor 130 133 131 134 = 2.2.0 = -
generateblocks/trunk/includes/class-meta-handler.php
r3415721 r3495827 267 267 268 268 if ( 'get_post_meta' === $callable ) { 269 if ( is_numeric( $id ) && ! current_user_can( 'read_post', (int) $id ) ) { 270 return ''; 271 } 272 269 273 if ( is_protected_meta( $key, 'post' ) ) { 270 274 return ''; … … 474 478 } 475 479 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 476 491 $key = $request->get_param( 'key' ); 477 492 $single_only = true; -
generateblocks/trunk/includes/class-query-utils.php
r3415721 r3495827 68 68 $args = $request->get_param( 'args' ) ?? []; 69 69 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 70 78 if ( ! isset( $args['number'] ) ) { 71 79 $args['number'] = 150; … … 87 95 unset( $user->data->user_login ); 88 96 unset( $user->data->user_email ); 97 98 // Remove capability data to prevent role enumeration. 99 unset( $user->caps ); 100 unset( $user->allcaps ); 89 101 } 90 102 -
generateblocks/trunk/includes/dynamic-tags/class-dynamic-tag-callbacks.php
r3415721 r3495827 63 63 break; 64 64 case 'author_email': 65 if ( defined( 'REST_REQUEST' ) && REST_REQUEST && ! current_user_can( 'list_users' ) ) { 66 break; 67 } 68 65 69 $user_id = get_post_field( 'post_author', $id ); 66 70 $url = 'mailto:' . get_the_author_meta( 'user_email', $user_id ); -
generateblocks/trunk/includes/dynamic-tags/class-dynamic-tags.php
r3415721 r3495827 503 503 $context = $request->get_param( 'context' ); 504 504 $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 506 512 $fallback_id = $post_id; 507 513 $instance = new stdClass(); … … 513 519 // Create a unique cache key. 514 520 $cache_key = sprintf( 515 'replacements_%s_%s_%s ',521 'replacements_%s_%s_%s_%s', 516 522 md5( $content ), 517 523 $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' ); 522 529 523 530 // Return the cache here if present. … … 555 562 if ( 'user' === $type ) { 556 563 $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 } 557 583 } 558 584 -
generateblocks/trunk/package.json
r3415721 r3495827 1 1 { 2 2 "name": "generateblocks", 3 "version": "2.2. 0",3 "version": "2.2.1", 4 4 "private": true, 5 5 "description": "A small collection of lightweight WordPress blocks that can accomplish nearly anything.", -
generateblocks/trunk/plugin.php
r3415721 r3495827 6 6 * Author: Tom Usborne 7 7 * Author URI: https://tomusborne.com 8 * Version: 2.2. 08 * Version: 2.2.1 9 9 * Requires at least: 6.5 10 10 * Requires PHP: 7.2 … … 20 20 } 21 21 22 define( 'GENERATEBLOCKS_VERSION', '2.2. 0' );22 define( 'GENERATEBLOCKS_VERSION', '2.2.1' ); 23 23 define( 'GENERATEBLOCKS_DIR', plugin_dir_path( __FILE__ ) ); 24 24 define( 'GENERATEBLOCKS_DIR_URL', plugin_dir_url( __FILE__ ) ); -
generateblocks/trunk/readme.txt
r3415721 r3495827 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.2 8 Stable tag: 2.2. 08 Stable tag: 2.2.1 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 128 128 129 129 == Changelog == 130 131 = 2.2.1 = 132 * Security: Improve dynamic tag replacement security in the editor 130 133 131 134 = 2.2.0 =
Note: See TracChangeset
for help on using the changeset viewer.