Changeset 56855
- Timestamp:
- 10/12/2023 02:31:27 PM (14 months ago)
- Location:
- branches/4.4/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.4/src/wp-admin/includes/ajax-actions.php
r55779 r56855 2981 2981 $shortcode = wp_unslash( $_POST['shortcode'] ); 2982 2982 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 2983 2999 if ( ! empty( $_POST['post_ID'] ) ) { 2984 3000 $post = get_post( (int) $_POST['post_ID'] ); … … 2987 3003 // the embed shortcode requires a post 2988 3004 if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { 2989 if ( 'embed' === $shortcode) {3005 if ( in_array( 'embed', $found_shortcodes, true ) ) { 2990 3006 wp_send_json_error(); 2991 3007 } -
branches/4.4/src/wp-admin/includes/class-wp-comments-list-table.php
r35748 r56855 496 496 $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID ); 497 497 498 $edit_post_cap = $post ? 'edit_post' : 'edit_posts'; 499 if ( 500 current_user_can( $edit_post_cap, $comment->comment_post_ID ) || 501 ( 502 empty( $post->post_password ) && 503 current_user_can( 'read_post', $comment->comment_post_ID ) 504 ) 505 ) { 506 // The user has access to the post 507 } else { 508 return false; 509 } 510 498 511 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>"; 499 512 $this->single_row_columns( $comment ); -
branches/4.4/src/wp-admin/includes/class-wp-list-table.php
r35819 r56855 656 656 $pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number ); 657 657 658 // No comments at all. 658 $post_object = get_post( $post_id ); 659 $edit_post_cap = $post_object ? 'edit_post' : 'edit_posts'; 660 if ( 661 current_user_can( $edit_post_cap, $post_id ) || 662 ( 663 empty( $post_object->post_password ) && 664 current_user_can( 'read_post', $post_id ) 665 ) 666 ) { 667 // The user has access to the post and thus can see comments 668 } else { 669 return false; 670 } 671 659 672 if ( ! $approved_comments && ! $pending_comments ) { 660 673 printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', -
branches/4.4/src/wp-admin/includes/dashboard.php
r35443 r56855 858 858 859 859 echo '<div id="the-comment-list" data-wp-lists="list:comment">'; 860 foreach ( $comments as $comment ) 861 _wp_dashboard_recent_comments_row( $comment ); 860 foreach ( $comments as $comment ) { 861 $comment_post = get_post( $comment->comment_post_ID ); 862 if ( 863 current_user_can( 'edit_post', $comment->comment_post_ID ) || 864 ( 865 empty( $comment_post->post_password ) && 866 current_user_can( 'read_post', $comment->comment_post_ID ) 867 ) 868 ) { 869 _wp_dashboard_recent_comments_row( $comment ); 870 } 871 } 862 872 echo '</div>'; 863 873 -
branches/4.4/src/wp-includes/class-wp-theme.php
r39812 r56855 520 520 521 521 /** 522 * Perform reinitialization tasks. 523 * 524 * Prevents a callback from being injected during unserialization of an object. 525 * 526 * @return void 527 */ 528 public function __wakeup() { 529 if ( $this->parent && ! $this->parent instanceof self ) { 530 throw new UnexpectedValueException(); 531 } 532 if ( $this->headers && ! is_array( $this->headers ) ) { 533 throw new UnexpectedValueException(); 534 } 535 foreach ( $this->headers as $value ) { 536 if ( ! is_string( $value ) ) { 537 throw new UnexpectedValueException(); 538 } 539 } 540 $this->headers_sanitized = array(); 541 } 542 543 /** 522 544 * Adds theme data to cache. 523 545 * … … 1330 1352 return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) ); 1331 1353 } 1354 1355 private static function _check_headers_property_has_correct_type( $headers ) { 1356 if ( ! is_array( $headers ) ) { 1357 return false; 1358 } 1359 foreach ( $headers as $key => $value ) { 1360 if ( ! is_string( $key ) || ! is_string( $value ) ) { 1361 return false; 1362 } 1363 } 1364 return true; 1365 } 1332 1366 } -
branches/4.4/src/wp-includes/media.php
r55779 r56855 1633 1633 } 1634 1634 } elseif ( ! empty( $atts['exclude'] ) ) { 1635 $post_parent_id = $id; 1635 1636 $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'] ) ); 1636 1637 } else { 1638 $post_parent_id = $id; 1637 1639 $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); 1640 } 1641 1642 if ( ! empty( $post_parent_id ) ) { 1643 $post_parent = get_post( $post_parent_id ); 1644 1645 // terminate the shortcode execution if user cannot read the post or password-protected 1646 if ( 1647 ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) ) 1648 || post_password_required( $post_parent ) ) { 1649 return ''; 1650 } 1638 1651 } 1639 1652 … … 1937 1950 } 1938 1951 1952 if ( ! empty( $args['post_parent'] ) ) { 1953 $post_parent = get_post( $id ); 1954 1955 // terminate the shortcode execution if user cannot read the post or password-protected 1956 if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) { 1957 return ''; 1958 } 1959 } 1960 1939 1961 if ( empty( $attachments ) ) { 1940 1962 return ''; -
branches/4.4/src/wp-includes/rest-api.php
r46498 r56855 575 575 576 576 if ( ! $result ) { 577 add_filter( 'rest_send_nocache_headers', '__return_true', 20 ); 577 578 return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie nonce is invalid' ), array( 'status' => 403 ) ); 578 579 } -
branches/4.4/src/wp-includes/rest-api/class-wp-rest-server.php
r35773 r56855 238 238 239 239 /** 240 * Send nocache headers on authenticated requests. 241 * 242 * @since 4.4.0 243 * 244 * @param bool $rest_send_nocache_headers Whether to send no-cache headers. 245 */ 246 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); 247 if ( $send_no_cache_headers ) { 248 foreach ( wp_get_nocache_headers() as $header => $header_value ) { 249 $this->send_header( $header, $header_value ); 250 } 251 } 252 253 /** 254 * Filter whether the REST API is enabled. 240 * Filters whether the REST API is enabled. 255 241 * 256 242 * @since 4.4.0 … … 315 301 * header. 316 302 */ 303 $method_overridden = false; 317 304 if ( isset( $_GET['_method'] ) ) { 318 305 $request->set_method( $_GET['_method'] ); 319 306 } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) { 320 307 $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ); 308 $method_overridden = true; 321 309 } 322 310 … … 375 363 */ 376 364 $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); 365 366 /** 367 * Filters whether to send nocache headers on a REST API request. 368 * 369 * @since 4.4.0 370 * @since 6.x.x Moved the block to catch the filter added on rest_cookie_check_errors() from rest-api.php 371 * 372 * @param bool $rest_send_nocache_headers Whether to send no-cache headers. 373 */ 374 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); 375 376 // send no cache headers if the $send_no_cache_headers is true 377 // OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4xx response code. 378 if ( $send_no_cache_headers || ( true === $method_overridden && strpos( $code, '4' ) === 0 ) ) { 379 foreach ( wp_get_nocache_headers() as $header => $header_value ) { 380 $this->send_header( $header, $header_value ); 381 } 382 } 377 383 378 384 if ( ! $served ) { -
branches/4.4/src/wp-includes/shortcodes.php
r36098 r56855 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.