mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Robots: Remove contradictory directive check in wp_robots().
Removes the mutually exclusive directives check in `wp_robots()`, ie allow both `follow` and `nofollow` to be specified and for `archive` and `noarchive` to be specified. This fixes a bug in which WordPress would defer to the most permissive over the least permissive. When contradictory instructions are included, WordPress will defer to the search engine's or archivist's resolution policy: generally this is to observe the least, not most permissive. Props Cybr, flixos90. Fixes #52713. git-svn-id: https://develop.svn.wordpress.org/trunk@50566 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -71,56 +71,6 @@ class Tests_Robots extends WP_UnitTestCase {
|
||||
$this->assertContains( "'{$expected_directives_string}'", $output );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 51511
|
||||
*/
|
||||
public function test_wp_robots_includes_basic_sanitization_follow_nofollow() {
|
||||
// Only follow or nofollow can be present, with follow taking precedence.
|
||||
add_filter( 'wp_robots', array( $this, 'add_follow_directive' ) );
|
||||
add_filter( 'wp_robots', array( $this, 'add_nofollow_directive' ) );
|
||||
$output = get_echo( 'wp_robots' );
|
||||
$this->assertContains( "'follow'", $output );
|
||||
|
||||
// Consider truthyness of the directive value though.
|
||||
// Here nofollow is true, follow is false.
|
||||
add_filter( 'wp_robots', array( $this, 'remove_follow_directive' ), 11 );
|
||||
add_filter( 'wp_robots', array( $this, 'add_nofollow_directive' ), 11 );
|
||||
$output = get_echo( 'wp_robots' );
|
||||
$this->assertContains( "'nofollow'", $output );
|
||||
|
||||
// Consider truthyness of the directive value though.
|
||||
// Here follow is true, nofollow is false.
|
||||
add_filter( 'wp_robots', array( $this, 'add_follow_directive' ), 12 );
|
||||
add_filter( 'wp_robots', array( $this, 'remove_nofollow_directive' ), 12 );
|
||||
$output = get_echo( 'wp_robots' );
|
||||
$this->assertContains( "'follow'", $output );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 51511
|
||||
*/
|
||||
public function test_wp_robots_includes_basic_sanitization_archive_noarchive() {
|
||||
// Only archive or noarchive can be present, with archive taking precedence.
|
||||
add_filter( 'wp_robots', array( $this, 'add_archive_directive' ) );
|
||||
add_filter( 'wp_robots', array( $this, 'add_noarchive_directive' ) );
|
||||
$output = get_echo( 'wp_robots' );
|
||||
$this->assertContains( "'archive'", $output );
|
||||
|
||||
// Consider truthyness of the directive value though.
|
||||
// Here noarchive is true, archive is false.
|
||||
add_filter( 'wp_robots', array( $this, 'remove_archive_directive' ), 11 );
|
||||
add_filter( 'wp_robots', array( $this, 'add_noarchive_directive' ), 11 );
|
||||
$output = get_echo( 'wp_robots' );
|
||||
$this->assertContains( "'noarchive'", $output );
|
||||
|
||||
// Consider truthyness of the directive value though.
|
||||
// Here archive is true, noarchive is false.
|
||||
add_filter( 'wp_robots', array( $this, 'add_archive_directive' ), 12 );
|
||||
add_filter( 'wp_robots', array( $this, 'remove_noarchive_directive' ), 12 );
|
||||
$output = get_echo( 'wp_robots' );
|
||||
$this->assertContains( "'archive'", $output );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 51511
|
||||
*/
|
||||
@@ -207,44 +157,4 @@ class Tests_Robots extends WP_UnitTestCase {
|
||||
$robots['noindex'] = false;
|
||||
return $robots;
|
||||
}
|
||||
|
||||
public function add_follow_directive( array $robots ) {
|
||||
$robots['follow'] = true;
|
||||
return $robots;
|
||||
}
|
||||
|
||||
public function remove_follow_directive( array $robots ) {
|
||||
$robots['follow'] = false;
|
||||
return $robots;
|
||||
}
|
||||
|
||||
public function add_nofollow_directive( array $robots ) {
|
||||
$robots['nofollow'] = true;
|
||||
return $robots;
|
||||
}
|
||||
|
||||
public function remove_nofollow_directive( array $robots ) {
|
||||
$robots['nofollow'] = false;
|
||||
return $robots;
|
||||
}
|
||||
|
||||
public function add_archive_directive( array $robots ) {
|
||||
$robots['archive'] = true;
|
||||
return $robots;
|
||||
}
|
||||
|
||||
public function remove_archive_directive( array $robots ) {
|
||||
$robots['archive'] = false;
|
||||
return $robots;
|
||||
}
|
||||
|
||||
public function add_noarchive_directive( array $robots ) {
|
||||
$robots['noarchive'] = true;
|
||||
return $robots;
|
||||
}
|
||||
|
||||
public function remove_noarchive_directive( array $robots ) {
|
||||
$robots['noarchive'] = false;
|
||||
return $robots;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user