Make WordPress Core


Ignore:
Timestamp:
09/06/2013 04:35:22 PM (13 years ago)
Author:
wonderboymusic
Message:

Check bad dates and redirect, instead of 404ing, as necessary and appropriate.
Adds query, conditional, and canonical Unit Tests.

Props kovshenin, SergeyBiryukov, DrewAPicture.
Fixes #10935.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r25269 r25280  
    15141514                        if ( $qv['day'] ) {
    15151515                                if ( ! $this->is_date ) {
    1516                                         $this->is_day = true;
    1517                                         $this->is_date = true;
     1516                                        $date = sprintf( '%04d-%02d-%02d', $qv['year'], $qv['monthnum'], $qv['day'] );
     1517                                        if ( $qv['monthnum'] && $qv['year'] && ! wp_checkdate( $qv['monthnum'], $qv['day'], $qv['year'], $date ) ) {
     1518                                                $qv['error'] = '404';
     1519                                        } else {
     1520                                                $this->is_day = true;
     1521                                                $this->is_date = true;
     1522                                        }
    15181523                                }
    15191524                        }
     
    15211526                        if ( $qv['monthnum'] ) {
    15221527                                if ( ! $this->is_date ) {
    1523                                         $this->is_month = true;
    1524                                         $this->is_date = true;
     1528                                        if ( 12 < $qv['monthnum'] ) {
     1529                                                $qv['error'] = '404';
     1530                                        } else {
     1531                                                $this->is_month = true;
     1532                                                $this->is_date = true;
     1533                                        }
    15251534                                }
    15261535                        }
Note: See TracChangeset for help on using the changeset viewer.