Make WordPress Core


Ignore:
Timestamp:
08/20/2016 02:31:31 AM (10 years ago)
Author:
boonebgorges
Message:

Query: Non-scalar and negative values for 'p' should always result in a 404.

Previously, the 'p' query var was being run through absint(), which
caused unexpected results.

Props Akeif, kouratoras.
Fixes #33372.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/query/parseQuery.php

    r29912 r38288  
    5252                $this->assertSame( true, $q->query_vars['s'] );
    5353        }
     54
     55        /**
     56         * @ticket 33372
     57         */
     58        public function test_parse_query_p_negative_int() {
     59                $q = new WP_Query();
     60                $q->parse_query( array(
     61                        'p' => -3,
     62                ) );
     63
     64                $this->assertSame( '404', $q->query_vars['error'] );
     65        }
     66
     67        /**
     68         * @ticket 33372
     69         */
     70        public function test_parse_query_p_array() {
     71                $q = new WP_Query();
     72                $q->parse_query( array(
     73                        'p' => array(),
     74                ) );
     75
     76                $this->assertSame( '404', $q->query_vars['error'] );
     77        }
     78
     79        /**
     80         * @ticket 33372
     81         */
     82        public function test_parse_query_p_object() {
     83                $q = new WP_Query();
     84                $q->parse_query( array(
     85                        'p' => new stdClass(),
     86                ) );
     87
     88                $this->assertSame( '404', $q->query_vars['error'] );
     89        }
     90
    5491}
Note: See TracChangeset for help on using the changeset viewer.