Changeset 56878
- Timestamp:
- 10/12/2023 03:06:49 PM (14 months ago)
- Location:
- branches/5.4
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.4
- Property svn:mergeinfo changed
/trunk merged: 56833-56836,56838
- Property svn:mergeinfo changed
-
branches/5.4/src/wp-admin/includes/ajax-actions.php
r55785 r56878 3740 3740 $shortcode = wp_unslash( $_POST['shortcode'] ); 3741 3741 3742 // Only process previews for media related shortcodes: 3743 $found_shortcodes = get_shortcode_tags_in_content( $shortcode ); 3744 $media_shortcodes = array( 3745 'audio', 3746 'embed', 3747 'playlist', 3748 'video', 3749 'gallery', 3750 ); 3751 3752 $other_shortcodes = array_diff( $found_shortcodes, $media_shortcodes ); 3753 3754 if ( ! empty( $other_shortcodes ) ) { 3755 wp_send_json_error(); 3756 } 3757 3742 3758 if ( ! empty( $_POST['post_ID'] ) ) { 3743 3759 $post = get_post( (int) $_POST['post_ID'] ); … … 3746 3762 // The embed shortcode requires a post. 3747 3763 if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { 3748 if ( 'embed' === $shortcode) {3764 if ( in_array( 'embed', $found_shortcodes, true ) ) { 3749 3765 wp_send_json_error(); 3750 3766 } -
branches/5.4/src/wp-admin/includes/class-wp-comments-list-table.php
r47234 r56878 562 562 $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID ); 563 563 564 $edit_post_cap = $post ? 'edit_post' : 'edit_posts'; 565 if ( 566 current_user_can( $edit_post_cap, $comment->comment_post_ID ) || 567 ( 568 empty( $post->post_password ) && 569 current_user_can( 'read_post', $comment->comment_post_ID ) 570 ) 571 ) { 572 // The user has access to the post 573 } else { 574 return false; 575 } 576 564 577 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>"; 565 578 $this->single_row_columns( $comment ); -
branches/5.4/src/wp-admin/includes/class-wp-list-table.php
r47219 r56878 683 683 ); 684 684 685 // No comments at all. 685 $post_object = get_post( $post_id ); 686 $edit_post_cap = $post_object ? 'edit_post' : 'edit_posts'; 687 if ( 688 current_user_can( $edit_post_cap, $post_id ) || 689 ( 690 empty( $post_object->post_password ) && 691 current_user_can( 'read_post', $post_id ) 692 ) 693 ) { 694 // The user has access to the post and thus can see comments 695 } else { 696 return false; 697 } 698 686 699 if ( ! $approved_comments && ! $pending_comments ) { 687 700 printf( -
branches/5.4/src/wp-admin/includes/dashboard.php
r47415 r56878 1035 1035 echo '<ul id="the-comment-list" data-wp-lists="list:comment">'; 1036 1036 foreach ( $comments as $comment ) { 1037 _wp_dashboard_recent_comments_row( $comment ); 1037 $comment_post = get_post( $comment->comment_post_ID ); 1038 if ( 1039 current_user_can( 'edit_post', $comment->comment_post_ID ) || 1040 ( 1041 empty( $comment_post->post_password ) && 1042 current_user_can( 'read_post', $comment->comment_post_ID ) 1043 ) 1044 ) { 1045 _wp_dashboard_recent_comments_row( $comment ); 1046 } 1038 1047 } 1039 1048 echo '</ul>'; -
branches/5.4/src/wp-includes/Requests/Hooks.php
r46586 r56878 66 66 return true; 67 67 } 68 69 public function __wakeup() { 70 throw new \LogicException( __CLASS__ . ' should never be unserialized' ); 71 } 68 72 } -
branches/5.4/src/wp-includes/Requests/IRI.php
r46586 r56878 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/5.4/src/wp-includes/Requests/Session.php
r46586 r56878 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/5.4/src/wp-includes/class-wp-block-type-registry.php
r46586 r56878 155 155 } 156 156 157 public function __wakeup() { 158 if ( ! $this->registered_block_types ) { 159 return; 160 } 161 if ( ! is_array( $this->registered_block_types ) ) { 162 throw new UnexpectedValueException(); 163 } 164 foreach ( $this->registered_block_types as $value ) { 165 if ( ! $value instanceof WP_Block_Type ) { 166 throw new UnexpectedValueException(); 167 } 168 } 169 } 170 157 171 /** 158 172 * Utility method to retrieve the main instance of the class. -
branches/5.4/src/wp-includes/class-wp-theme.php
r47397 r56878 677 677 678 678 /** 679 * Perform reinitialization tasks. 680 * 681 * Prevents a callback from being injected during unserialization of an object. 682 * 683 * @return void 684 */ 685 public function __wakeup() { 686 if ( $this->parent && ! $this->parent instanceof self ) { 687 throw new UnexpectedValueException(); 688 } 689 if ( $this->headers && ! is_array( $this->headers ) ) { 690 throw new UnexpectedValueException(); 691 } 692 foreach ( $this->headers as $value ) { 693 if ( ! is_string( $value ) ) { 694 throw new UnexpectedValueException(); 695 } 696 } 697 $this->headers_sanitized = array(); 698 } 699 700 /** 679 701 * Adds theme data to cache. 680 702 * … … 1668 1690 return strnatcasecmp( $a->name_translated, $b->name_translated ); 1669 1691 } 1692 1693 private static function _check_headers_property_has_correct_type( $headers ) { 1694 if ( ! is_array( $headers ) ) { 1695 return false; 1696 } 1697 foreach ( $headers as $key => $value ) { 1698 if ( ! is_string( $key ) || ! is_string( $value ) ) { 1699 return false; 1700 } 1701 } 1702 return true; 1703 } 1670 1704 } -
branches/5.4/src/wp-includes/media.php
r55785 r56878 1931 1931 } 1932 1932 } elseif ( ! empty( $atts['exclude'] ) ) { 1933 $attachments = get_children( 1933 $post_parent_id = $id; 1934 $attachments = get_children( 1934 1935 array( 1935 1936 'post_parent' => $id, … … 1943 1944 ); 1944 1945 } else { 1945 $attachments = get_children( 1946 $post_parent_id = $id; 1947 $attachments = get_children( 1946 1948 array( 1947 1949 'post_parent' => $id, … … 1953 1955 ) 1954 1956 ); 1957 } 1958 1959 if ( ! empty( $post_parent_id ) ) { 1960 $post_parent = get_post( $post_parent_id ); 1961 1962 // terminate the shortcode execution if user cannot read the post or password-protected 1963 if ( 1964 ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) ) 1965 || post_password_required( $post_parent ) ) { 1966 return ''; 1967 } 1955 1968 } 1956 1969 … … 2273 2286 } 2274 2287 2288 if ( ! empty( $args['post_parent'] ) ) { 2289 $post_parent = get_post( $id ); 2290 2291 // terminate the shortcode execution if user cannot read the post or password-protected 2292 if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) { 2293 return ''; 2294 } 2295 } 2296 2275 2297 if ( empty( $attachments ) ) { 2276 2298 return ''; -
branches/5.4/src/wp-includes/rest-api.php
r47843 r56878 921 921 922 922 if ( ! $result ) { 923 add_filter( 'rest_send_nocache_headers', '__return_true', 20 ); 923 924 return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie nonce is invalid' ), array( 'status' => 403 ) ); 924 925 } -
branches/5.4/src/wp-includes/rest-api/class-wp-rest-server.php
r47351 r56878 248 248 249 249 /** 250 * Send nocache headers on authenticated requests.251 *252 * @since 4.4.0253 *254 * @param bool $rest_send_nocache_headers Whether to send no-cache headers.255 */256 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );257 if ( $send_no_cache_headers ) {258 foreach ( wp_get_nocache_headers() as $header => $header_value ) {259 if ( empty( $header_value ) ) {260 $this->remove_header( $header );261 } else {262 $this->send_header( $header, $header_value );263 }264 }265 }266 267 /**268 250 * Filters whether the REST API is enabled. 269 251 * … … 331 313 * header. 332 314 */ 315 $method_overridden = false; 333 316 if ( isset( $_GET['_method'] ) ) { 334 317 $request->set_method( $_GET['_method'] ); 335 318 } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) { 336 319 $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ); 320 $method_overridden = true; 337 321 } 338 322 … … 392 376 */ 393 377 $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); 378 379 /** 380 * Filters whether to send nocache headers on a REST API request. 381 * 382 * @since 4.4.0 383 * @since 6.x.x Moved the block to catch the filter added on rest_cookie_check_errors() from rest-api.php 384 * 385 * @param bool $rest_send_nocache_headers Whether to send no-cache headers. 386 */ 387 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); 388 389 // send no cache headers if the $send_no_cache_headers is true 390 // OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4xx response code. 391 if ( $send_no_cache_headers || ( true === $method_overridden && strpos( $code, '4' ) === 0 ) ) { 392 foreach ( wp_get_nocache_headers() as $header => $header_value ) { 393 if ( empty( $header_value ) ) { 394 $this->remove_header( $header ); 395 } else { 396 $this->send_header( $header, $header_value ); 397 } 398 } 399 } 394 400 395 401 if ( ! $served ) { -
branches/5.4/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r47397 r56878 303 303 304 304 if ( ! empty( $prepared_args['search'] ) ) { 305 if ( ! current_user_can( 'list_users' ) ) { 306 $prepared_args['search_columns'] = array( 'ID', 'user_login', 'user_nicename', 'display_name' ); 307 } 305 308 $prepared_args['search'] = '*' . $prepared_args['search'] . '*'; 306 309 } -
branches/5.4/src/wp-includes/shortcodes.php
r47219 r56878 161 161 162 162 /** 163 * Search content for shortcodes and filter shortcodes through their hooks. 163 * Returns a list of registered shortcode names found in the given content. 164 * 165 * Example usage: 166 * 167 * get_shortcode_tags_in_content( '[audio src="file.mp3"][/audio] [foo] [gallery ids="1,2,3"]' ); 168 * // array( 'audio', 'gallery' ) 169 * 170 * @since 6.3.2 171 * 172 * @param string $content The content to check. 173 * @return string[] An array of registered shortcode names found in the content. 174 */ 175 function get_shortcode_tags_in_content( $content ) { 176 if ( false === strpos( $content, '[' ) ) { 177 return array(); 178 } 179 180 preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER ); 181 if ( empty( $matches ) ) { 182 return array(); 183 } 184 185 $tags = array(); 186 foreach ( $matches as $shortcode ) { 187 $tags[] = $shortcode[2]; 188 189 if ( ! empty( $shortcode[5] ) ) { 190 $deep_tags = get_shortcode_tags_in_content( $shortcode[5] ); 191 if ( ! empty( $deep_tags ) ) { 192 $tags = array_merge( $tags, $deep_tags ); 193 } 194 } 195 } 196 197 return $tags; 198 } 199 200 /** 201 * Searches content for shortcodes and filter shortcodes through their hooks. 164 202 * 165 203 * This function is an alias for do_shortcode().
Note: See TracChangeset
for help on using the changeset viewer.