Ticket #10935: canonical-bad-dates.diff
| File canonical-bad-dates.diff, 2.9 KB (added by , 14 years ago) |
|---|
-
wp-includes/functions.php
3497 3497 } 3498 3498 3499 3499 /** 3500 * Validates day as 1-31 or specific to month when passed 3501 * 3502 * @since 3.5.0 3503 * @param int $day 3504 * @param int $month 3505 * @return bool 3506 */ 3507 function wp_is_valid_day( $day, $month, $year ) { 3508 return checkdate( $month, $day, $year ); 3509 } 3510 3511 /** 3512 * Validates month as 1-12 3513 * 3514 * @since 3.5.0 3515 * @param int $month 3516 * @return bool 3517 */ 3518 function wp_is_valid_month( $month ) { 3519 $month = (int) $month; 3520 3521 return ! ( empty( $month ) || 12 < $month ); 3522 } 3523 3524 /** 3500 3525 * Finds hierarchy loops using a callback function that maps object IDs to parent IDs. 3501 3526 * 3502 3527 * @since 3.1.0 -
wp-includes/query.php
1501 1501 1502 1502 if ( $qv['day'] ) { 1503 1503 if ( ! $this->is_date ) { 1504 $this->is_day = true; 1505 $this->is_date = true; 1504 if ( $qv['monthnum'] && $qv['year'] && ! wp_is_valid_day( $qv['day'], $qv['monthnum'], $qv['year'] ) ) { 1505 $qv['error'] = '404'; 1506 } else { 1507 $this->is_day = true; 1508 $this->is_date = true; 1509 } 1506 1510 } 1507 1511 } 1508 1512 1509 if ( $qv['monthnum'] ) { 1513 if ( $qv['monthnum'] ) { 1510 1514 if ( ! $this->is_date ) { 1511 $this->is_month = true; 1512 $this->is_date = true; 1515 if ( wp_is_valid_month( $qv['monthnum'] ) ) { 1516 $this->is_month = true; 1517 $this->is_date = true; 1518 } else { 1519 $qv['error'] = '404'; 1520 } 1513 1521 } 1514 1522 } 1515 1523 -
wp-includes/canonical.php
101 101 } 102 102 } 103 103 104 if ( get_query_var( 'day' ) && get_query_var( 'monthnum' ) && get_query_var( 'year' ) && ! wp_is_valid_day( get_query_var( 'day' ), get_query_var( 'monthnum' ), get_query_var( 'year' ) ) ) { 105 $redirect_url = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) ); 106 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum', 'day' ), $redirect_url ); 107 } elseif ( get_query_var( 'monthnum' ) && get_query_var( 'year' ) && ! wp_is_valid_month( get_query_var( 'monthnum' ) ) ) { 108 $redirect_url = get_year_link( get_query_var( 'year' ) ); 109 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'year', 'monthnum' ), $redirect_url ); 110 } 111 104 112 if ( ! $redirect_url ) { 105 113 if ( $redirect_url = redirect_guess_404_permalink() ) { 106 114 $redirect['query'] = _remove_qs_args_if_not_in_url( $redirect['query'], array( 'page', 'feed', 'p', 'page_id', 'attachment_id', 'pagename', 'name', 'post_type' ), $redirect_url );