mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
General: Add noindex robots meta tag to search results.
Prevent search engines indexing internal search results to protect against reflected web spam attacks. Props abagtcs, audrasjb, ayeshrajans, burtrw, johnbillion, jonoaldersonwp, peterwilsoncc, poena, sabernhardt, xkon. Fixes #52457 git-svn-id: https://develop.svn.wordpress.org/trunk@50370 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -176,6 +176,28 @@ class Tests_Robots extends WP_UnitTestCase {
|
||||
$this->assertEmpty( $output );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52457
|
||||
*/
|
||||
public function test_wp_robots_search_page() {
|
||||
add_filter( 'wp_robots', 'wp_robots_noindex_search' );
|
||||
$this->go_to( home_url( '?s=ticket+52457+core.trac.wordpress.org' ) );
|
||||
|
||||
$output = get_echo( 'wp_robots' );
|
||||
$this->assertContains( 'noindex', $output );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52457
|
||||
*/
|
||||
public function test_wp_robots_non_search_page() {
|
||||
add_filter( 'wp_robots', 'wp_robots_noindex_search' );
|
||||
$this->go_to( home_url() );
|
||||
|
||||
$output = get_echo( 'wp_robots' );
|
||||
$this->assertNotContains( 'noindex', $output );
|
||||
}
|
||||
|
||||
public function add_noindex_directive( array $robots ) {
|
||||
$robots['noindex'] = true;
|
||||
return $robots;
|
||||
|
||||
Reference in New Issue
Block a user