Changeset 56862 for branches/4.7
- Timestamp:
- 10/12/2023 02:48:17 PM (14 months ago)
- Location:
- branches/4.7/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7/src/wp-admin/includes/ajax-actions.php
r55784 r56862 3044 3044 $shortcode = wp_unslash( $_POST['shortcode'] ); 3045 3045 3046 // Only process previews for media related shortcodes: 3047 $found_shortcodes = get_shortcode_tags_in_content( $shortcode ); 3048 $media_shortcodes = array( 3049 'audio', 3050 'embed', 3051 'playlist', 3052 'video', 3053 'gallery', 3054 ); 3055 3056 $other_shortcodes = array_diff( $found_shortcodes, $media_shortcodes ); 3057 3058 if ( ! empty( $other_shortcodes ) ) { 3059 wp_send_json_error(); 3060 } 3061 3046 3062 if ( ! empty( $_POST['post_ID'] ) ) { 3047 3063 $post = get_post( (int) $_POST['post_ID'] ); … … 3050 3066 // the embed shortcode requires a post 3051 3067 if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { 3052 if ( 'embed' === $shortcode) {3068 if ( in_array( 'embed', $found_shortcodes, true ) ) { 3053 3069 wp_send_json_error(); 3054 3070 } -
branches/4.7/src/wp-admin/includes/class-wp-comments-list-table.php
r38672 r56862 495 495 $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID ); 496 496 497 $edit_post_cap = $post ? 'edit_post' : 'edit_posts'; 498 if ( 499 current_user_can( $edit_post_cap, $comment->comment_post_ID ) || 500 ( 501 empty( $post->post_password ) && 502 current_user_can( 'read_post', $comment->comment_post_ID ) 503 ) 504 ) { 505 // The user has access to the post 506 } else { 507 return false; 508 } 509 497 510 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>"; 498 511 $this->single_row_columns( $comment ); -
branches/4.7/src/wp-admin/includes/class-wp-list-table.php
r38672 r56862 655 655 $pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number ); 656 656 657 // No comments at all. 657 $post_object = get_post( $post_id ); 658 $edit_post_cap = $post_object ? 'edit_post' : 'edit_posts'; 659 if ( 660 current_user_can( $edit_post_cap, $post_id ) || 661 ( 662 empty( $post_object->post_password ) && 663 current_user_can( 'read_post', $post_id ) 664 ) 665 ) { 666 // The user has access to the post and thus can see comments 667 } else { 668 return false; 669 } 670 658 671 if ( ! $approved_comments && ! $pending_comments ) { 659 672 printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', -
branches/4.7/src/wp-admin/includes/dashboard.php
r39326 r56862 920 920 921 921 echo '<ul id="the-comment-list" data-wp-lists="list:comment">'; 922 foreach ( $comments as $comment ) 923 _wp_dashboard_recent_comments_row( $comment ); 922 foreach ( $comments as $comment ) { 923 $comment_post = get_post( $comment->comment_post_ID ); 924 if ( 925 current_user_can( 'edit_post', $comment->comment_post_ID ) || 926 ( 927 empty( $comment_post->post_password ) && 928 current_user_can( 'read_post', $comment->comment_post_ID ) 929 ) 930 ) { 931 _wp_dashboard_recent_comments_row( $comment ); 932 } 933 } 924 934 echo '</ul>'; 925 935 -
branches/4.7/src/wp-includes/Requests/Hooks.php
r38049 r56862 66 66 return true; 67 67 } 68 69 public function __wakeup() { 70 throw new \LogicException( __CLASS__ . ' should never be unserialized' ); 71 } 68 72 } -
branches/4.7/src/wp-includes/Requests/IRI.php
r38727 r56862 704 704 } 705 705 706 public function __wakeup() { 707 $class_props = get_class_vars( __CLASS__ ); 708 $string_props = array( 'scheme', 'iuserinfo', 'ihost', 'port', 'ipath', 'iquery', 'ifragment' ); 709 $array_props = array( 'normalization' ); 710 foreach ( $class_props as $prop => $default_value ) { 711 if ( in_array( $prop, $string_props, true ) && ! is_string( $this->$prop ) ) { 712 throw new UnexpectedValueException(); 713 } elseif ( in_array( $prop, $array_props, true ) && ! is_array( $this->$prop ) ) { 714 throw new UnexpectedValueException(); 715 } 716 $this->$prop = null; 717 } 718 } 719 706 720 /** 707 721 * Set the entire IRI. Returns true on success, false on failure (if there -
branches/4.7/src/wp-includes/Requests/Session.php
r38049 r56862 228 228 } 229 229 230 public function __wakeup() { 231 throw new \LogicException( __CLASS__ . ' should never be unserialized' ); 232 } 233 230 234 /** 231 235 * Merge a request's data with the default data -
branches/4.7/src/wp-includes/class-wp-theme.php
r40326 r56862 532 532 533 533 /** 534 * Perform reinitialization tasks. 535 * 536 * Prevents a callback from being injected during unserialization of an object. 537 * 538 * @return void 539 */ 540 public function __wakeup() { 541 if ( $this->parent && ! $this->parent instanceof self ) { 542 throw new UnexpectedValueException(); 543 } 544 if ( $this->headers && ! is_array( $this->headers ) ) { 545 throw new UnexpectedValueException(); 546 } 547 foreach ( $this->headers as $value ) { 548 if ( ! is_string( $value ) ) { 549 throw new UnexpectedValueException(); 550 } 551 } 552 $this->headers_sanitized = array(); 553 } 554 555 /** 534 556 * Adds theme data to cache. 535 557 * … … 1497 1519 return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) ); 1498 1520 } 1521 1522 private static function _check_headers_property_has_correct_type( $headers ) { 1523 if ( ! is_array( $headers ) ) { 1524 return false; 1525 } 1526 foreach ( $headers as $key => $value ) { 1527 if ( ! is_string( $key ) || ! is_string( $value ) ) { 1528 return false; 1529 } 1530 } 1531 return true; 1532 } 1499 1533 } -
branches/4.7/src/wp-includes/media.php
r55784 r56862 1688 1688 } 1689 1689 } elseif ( ! empty( $atts['exclude'] ) ) { 1690 $post_parent_id = $id; 1690 1691 $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); 1691 1692 } else { 1693 $post_parent_id = $id; 1692 1694 $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); 1695 } 1696 1697 if ( ! empty( $post_parent_id ) ) { 1698 $post_parent = get_post( $post_parent_id ); 1699 1700 // terminate the shortcode execution if user cannot read the post or password-protected 1701 if ( 1702 ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) ) 1703 || post_password_required( $post_parent ) ) { 1704 return ''; 1705 } 1693 1706 } 1694 1707 … … 1992 2005 } 1993 2006 2007 if ( ! empty( $args['post_parent'] ) ) { 2008 $post_parent = get_post( $id ); 2009 2010 // terminate the shortcode execution if user cannot read the post or password-protected 2011 if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) { 2012 return ''; 2013 } 2014 } 2015 1994 2016 if ( empty( $attachments ) ) { 1995 2017 return ''; -
branches/4.7/src/wp-includes/rest-api.php
r46495 r56862 726 726 727 727 if ( ! $result ) { 728 add_filter( 'rest_send_nocache_headers', '__return_true', 20 ); 728 729 return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie nonce is invalid' ), array( 'status' => 403 ) ); 729 730 } -
branches/4.7/src/wp-includes/rest-api/class-wp-rest-server.php
r40336 r56862 244 244 245 245 /** 246 * Send nocache headers on authenticated requests.247 *248 * @since 4.4.0249 *250 * @param bool $rest_send_nocache_headers Whether to send no-cache headers.251 */252 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );253 if ( $send_no_cache_headers ) {254 foreach ( wp_get_nocache_headers() as $header => $header_value ) {255 $this->send_header( $header, $header_value );256 }257 }258 259 /**260 246 * Filters whether the REST API is enabled. 261 247 * … … 312 298 * header. 313 299 */ 300 $method_overridden = false; 314 301 if ( isset( $_GET['_method'] ) ) { 315 302 $request->set_method( $_GET['_method'] ); 316 303 } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) { 317 304 $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ); 305 $method_overridden = true; 318 306 } 319 307 … … 373 361 */ 374 362 $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); 363 364 /** 365 * Filters whether to send nocache headers on a REST API request. 366 * 367 * @since 4.4.0 368 * @since 6.x.x Moved the block to catch the filter added on rest_cookie_check_errors() from rest-api.php 369 * 370 * @param bool $rest_send_nocache_headers Whether to send no-cache headers. 371 */ 372 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); 373 374 // send no cache headers if the $send_no_cache_headers is true 375 // OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4xx response code. 376 if ( $send_no_cache_headers || ( true === $method_overridden && strpos( $code, '4' ) === 0 ) ) { 377 foreach ( wp_get_nocache_headers() as $header => $header_value ) { 378 $this->send_header( $header, $header_value ); 379 } 380 } 375 381 376 382 if ( ! $served ) { -
branches/4.7/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r40426 r56862 260 260 261 261 if ( ! empty( $prepared_args['search'] ) ) { 262 if ( ! current_user_can( 'list_users' ) ) { 263 $prepared_args['search_columns'] = array( 'ID', 'user_login', 'user_nicename', 'display_name' ); 264 } 262 265 $prepared_args['search'] = '*' . $prepared_args['search'] . '*'; 263 266 } -
branches/4.7/src/wp-includes/shortcodes.php
r39351 r56862 186 186 187 187 /** 188 * Search content for shortcodes and filter shortcodes through their hooks. 188 * Returns a list of registered shortcode names found in the given content. 189 * 190 * Example usage: 191 * 192 * get_shortcode_tags_in_content( '[audio src="file.mp3"][/audio] [foo] [gallery ids="1,2,3"]' ); 193 * // array( 'audio', 'gallery' ) 194 * 195 * @since 6.3.2 196 * 197 * @param string $content The content to check. 198 * @return string[] An array of registered shortcode names found in the content. 199 */ 200 function get_shortcode_tags_in_content( $content ) { 201 if ( false === strpos( $content, '[' ) ) { 202 return array(); 203 } 204 205 preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER ); 206 if ( empty( $matches ) ) { 207 return array(); 208 } 209 210 $tags = array(); 211 foreach ( $matches as $shortcode ) { 212 $tags[] = $shortcode[2]; 213 214 if ( ! empty( $shortcode[5] ) ) { 215 $deep_tags = get_shortcode_tags_in_content( $shortcode[5] ); 216 if ( ! empty( $deep_tags ) ) { 217 $tags = array_merge( $tags, $deep_tags ); 218 } 219 } 220 } 221 222 return $tags; 223 } 224 225 /** 226 * Searches content for shortcodes and filter shortcodes through their hooks. 189 227 * 190 228 * If there are no shortcode tags defined, then the content will be returned
Note: See TracChangeset
for help on using the changeset viewer.