Skip to content

Commit

Permalink
Merge pull request #1981 from Automattic/fix/prevent-invalid-query-args
Browse files Browse the repository at this point in the history
Prevent invalid core query args
  • Loading branch information
Brandon Skinner authored Feb 10, 2021
2 parents 458e2bc + 240ac87 commit d261bb4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions 001-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,25 @@ function( $can_edit, $post ) {
20,
2
);

/**
* Prevent invalid query args from causing php errors & a limitless query.
*
* This patch can be removed when the following core ticket is resolved:
* @see https://core.trac.wordpress.org/ticket/17737
*/
function vip_prevent_invalid_core_query_args() {
if ( is_admin() ) {
return;
}

if ( isset( $_GET['name'] ) && ! is_string( $_GET['name'] ) ) {
unset( $_GET['name'] );
}

if ( isset( $_GET['pagename'] ) && ! is_string( $_GET['pagename'] ) ) {
unset( $_GET['pagename'] );
}
}

add_action( 'wp_loaded', 'vip_prevent_invalid_core_query_args', 1 );

0 comments on commit d261bb4

Please sign in to comment.