[wp-trac] [WordPress Trac] #29736: Proposal to check for is_scalar() in WP_Query::fill_query_vars()

WordPress Trac noreply at wordpress.org
Wed Sep 24 00:01:01 UTC 2014


#29736: Proposal to check for is_scalar() in WP_Query::fill_query_vars()
-------------------------+-----------------------------
 Reporter:  tivnet       |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Query        |    Version:
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 '''The Symptom:'''

 `PHP Warning:  strlen() expects parameter 1 to be string, array given in
 .../wp-includes/query.php on line 1577`

 '''The line:'''

 `if ( ! empty( $qv['s'] ) && strlen( $qv['s'] ) > 1600 )`

 '''The cause (hacker's script):'''

 `http://www.example.com/?s[]=something`

 The `'s'` becomes an array, causing a sequence of warnings

 '''My quick patch in the core:'''

 {{{
 if ( ! is_scalar( $array['s'] ) ) {
         $array['s'] = '';
 }
 }}}

 '''A patch outside the core, until there is a upgrade:'''

 {{{
 /** Hooked to 'parse_request' */
 function action_parse_request(WP $query_args) {
         if ( ! is_scalar( $query_args->query_vars['s'] ) ) {
                 $query_args->query_vars['s'] = '';
         }
 }

 }}}

 '''The proposal:'''

 To check all (or most of) variables in the `fill_query_vars()`'s first
 loop for `is_scalar()`

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29736>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list