[wp-trac] [WordPress Trac] #50067: Notice if arg passed is an array in author

WordPress Trac noreply at wordpress.org
Sun May 3 11:38:23 UTC 2020


#50067: Notice if arg passed is an array in author
--------------------------+-----------------------------
 Reporter:  malthert      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Canonical     |    Version:  5.4
 Severity:  normal        |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------------
 If bots try urls like: /?author[]=1
 The following code will give a notice:
 Warning: preg_match() expects parameter 2 to be string, array given

 `} elseif ( is_author() && ! empty( $_GET['author'] ) && preg_match(
 '|^[0-9]+$|', $_GET['author'] ) ) {`


 Fix:

 ```
 } elseif ( is_author() && ! empty( $_GET['author'] ) && ! is_array(
 $_GET['author'] ) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) {
 ```

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


More information about the wp-trac mailing list