Changeset 56362
- Timestamp:
- 08/07/2023 09:59:20 AM (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp.php
r56180 r56362 206 206 } else { 207 207 // If the request uri is the index, blank it out so that we don't try to match it against a rule. 208 if ( $req_uri == $wp_rewrite->index ) {208 if ( $req_uri === $wp_rewrite->index ) { 209 209 $req_uri = ''; 210 210 } 211 211 212 $requested_path = $req_uri; 212 213 } 214 213 215 $requested_file = $req_uri; 214 216 … … 227 229 foreach ( (array) $rewrite as $match => $query ) { 228 230 // If the requested file is the anchor of the match, prepend it to the path info. 229 if ( ! empty( $requested_file ) && str_starts_with( $match, $requested_file ) && $requested_file != $requested_path ) { 231 if ( ! empty( $requested_file ) 232 && str_starts_with( $match, $requested_file ) 233 && $requested_file !== $requested_path 234 ) { 230 235 $request_match = $requested_file . '/' . $requested_path; 231 236 } 232 237 233 if ( preg_match( "#^$match#", $request_match, $matches ) || 234 preg_match( "#^$match#", urldecode( $request_match ), $matches ) ) { 235 236 if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) { 238 if ( preg_match( "#^$match#", $request_match, $matches ) 239 || preg_match( "#^$match#", urldecode( $request_match ), $matches ) 240 ) { 241 242 if ( $wp_rewrite->use_verbose_page_rules 243 && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) 244 ) { 237 245 // This is a verbose page match, let's check to be sure about it. 238 246 $page = get_page_by_path( $matches[ $varmatch[1] ] ); 247 239 248 if ( ! $page ) { 240 249 continue; … … 242 251 243 252 $post_status_obj = get_post_status_object( $page->post_status ); 253 244 254 if ( ! $post_status_obj->public && ! $post_status_obj->protected 245 && ! $post_status_obj->private && $post_status_obj->exclude_from_search ) { 255 && ! $post_status_obj->private && $post_status_obj->exclude_from_search 256 ) { 246 257 continue; 247 258 } … … 268 279 269 280 // If we're processing a 404 request, clear the error var since we found something. 270 if ( '404' == $error ) {281 if ( '404' === $error ) { 271 282 unset( $error, $_GET['error'] ); 272 283 } … … 274 285 275 286 // If req_uri is empty or if it is a request for ourself, unset error. 276 if ( empty( $requested_path ) || $requested_file == $self || str_contains( $_SERVER['PHP_SELF'], 'wp-admin/' ) ) { 287 if ( empty( $requested_path ) || $requested_file === $self 288 || str_contains( $_SERVER['PHP_SELF'], 'wp-admin/' ) 289 ) { 277 290 unset( $error, $_GET['error'] ); 278 291 … … 307 320 if ( isset( $this->extra_query_vars[ $wpvar ] ) ) { 308 321 $this->query_vars[ $wpvar ] = $this->extra_query_vars[ $wpvar ]; 309 } elseif ( isset( $_GET[ $wpvar ] ) && isset( $_POST[ $wpvar ] ) && $_GET[ $wpvar ] !== $_POST[ $wpvar ] ) { 310 wp_die( __( 'A variable mismatch has been detected.' ), __( 'Sorry, you are not allowed to view this item.' ), 400 ); 322 } elseif ( isset( $_GET[ $wpvar ] ) && isset( $_POST[ $wpvar ] ) 323 && $_GET[ $wpvar ] !== $_POST[ $wpvar ] 324 ) { 325 wp_die( 326 __( 'A variable mismatch has been detected.' ), 327 __( 'Sorry, you are not allowed to view this item.' ), 328 400 329 ); 311 330 } elseif ( isset( $_POST[ $wpvar ] ) ) { 312 331 $this->query_vars[ $wpvar ] = $_POST[ $wpvar ]; … … 358 377 if ( isset( $this->query_vars['post_type'] ) ) { 359 378 $queryable_post_types = get_post_types( array( 'publicly_queryable' => true ) ); 379 360 380 if ( ! is_array( $this->query_vars['post_type'] ) ) { 361 381 if ( ! in_array( $this->query_vars['post_type'], $queryable_post_types, true ) ) { … … 435 455 if ( ! empty( $this->query_vars['error'] ) ) { 436 456 $status = (int) $this->query_vars['error']; 457 437 458 if ( 404 === $status ) { 438 459 if ( ! is_user_logged_in() ) { 439 460 $headers = array_merge( $headers, wp_get_nocache_headers() ); 440 461 } 462 441 463 $headers['Content-Type'] = get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ); 442 464 } elseif ( in_array( $status, array( 403, 500, 502, 503 ), true ) ) { … … 451 473 $type = get_default_feed(); 452 474 } 475 453 476 $headers['Content-Type'] = feed_content_type( $type ) . '; charset=' . get_option( 'blog_charset' ); 454 477 … … 468 491 $wp_last_modified_post = mysql2date( $date_format, get_lastpostmodified( 'GMT' ), false ); 469 492 $wp_last_modified_comment = mysql2date( $date_format, get_lastcommentmodified( 'GMT' ), false ); 493 470 494 if ( strtotime( $wp_last_modified_post ) > strtotime( $wp_last_modified_comment ) ) { 471 495 $wp_last_modified = $wp_last_modified_post; … … 502 526 503 527 if ( ( $client_last_modified && $client_etag ) ? 504 ( ( $client_modified_timestamp >= $wp_modified_timestamp ) && ( $client_etag == $wp_etag ) ) : 505 ( ( $client_modified_timestamp >= $wp_modified_timestamp ) || ( $client_etag == $wp_etag ) ) ) { 528 ( ( $client_modified_timestamp >= $wp_modified_timestamp ) && ( $client_etag === $wp_etag ) ) : 529 ( ( $client_modified_timestamp >= $wp_modified_timestamp ) || ( $client_etag === $wp_etag ) ) 530 ) { 506 531 $status = 304; 507 532 $exit_required = true; … … 571 596 public function build_query_string() { 572 597 $this->query_string = ''; 598 573 599 foreach ( (array) array_keys( $this->query_vars ) as $wpvar ) { 574 if ( '' != $this->query_vars[ $wpvar ] ) {600 if ( '' !== $this->query_vars[ $wpvar ] ) { 575 601 $this->query_string .= ( strlen( $this->query_string ) < 1 ) ? '' : '&'; 602 576 603 if ( ! is_scalar( $this->query_vars[ $wpvar ] ) ) { // Discard non-scalars. 577 604 continue; 578 605 } 606 579 607 $this->query_string .= $wpvar . '=' . rawurlencode( $this->query_vars[ $wpvar ] ); 580 608 } … … 596 624 'query_vars, request' 597 625 ); 626 598 627 parse_str( $this->query_string, $this->query_vars ); 599 628 }
Note: See TracChangeset
for help on using the changeset viewer.