mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
“The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included.” With this commit, all occurrences of “whitelist” and “blacklist” (with the single exception of the `$new_whitelist_options` global variable) are removed. A new ticket has been opened to explore renaming the `$new_whitelist_options` variable (#50434). Changing to more specific names or rewording sentences containing these terms not only makes the code more inclusive, but also helps provide clarity. These terms are often ambiguous. What is being blocked or allowed is not always immediately clear. This can make it more difficult for non-native English speakers to read through the codebase. Words matter. If one contributor feels more welcome because these terms are removed, this was worth the effort. Props strangerstudios, jorbin, desrosj, joemcgill, timothyblynjacobs, ocean90, ayeshrajans, davidbaumwald, earnjam. See #48900, #50434. Fixes #50413. git-svn-id: https://develop.svn.wordpress.org/trunk@48121 602fd350-edb4-49c9-b593-d223f7449a82
104 lines
3.3 KiB
PHP
104 lines
3.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group comment
|
|
*/
|
|
class Tests_WP_Blocklist_Check extends WP_UnitTestCase {
|
|
|
|
public function test_should_return_true_when_content_matches_blocklist_keys() {
|
|
$author = 'Sting';
|
|
$author_email = 'sting@example.com';
|
|
$author_url = 'http://example.com';
|
|
$comment = "There's a hole in my heart. As deep as a well. For that poor little boy. Who's stuck halfway to Hell.";
|
|
$author_ip = '192.168.0.1';
|
|
$user_agent = '';
|
|
|
|
update_option( 'blocklist_keys', "well\nfoo" );
|
|
|
|
$result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
|
|
|
|
$this->assertTrue( $result );
|
|
}
|
|
|
|
/**
|
|
* @ticket 37208
|
|
*/
|
|
public function test_should_return_true_when_content_with_html_matches_blocklist_keys() {
|
|
$author = 'Sting';
|
|
$author_email = 'sting@example.com';
|
|
$author_url = 'http://example.com';
|
|
$comment = "There's a hole in my heart. As deep as a well. For that poor little boy. Who's stuck <b>half</b>way to Hell.";
|
|
$author_ip = '192.168.0.1';
|
|
$user_agent = '';
|
|
|
|
update_option( 'blocklist_keys', "halfway\nfoo" );
|
|
|
|
$result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
|
|
|
|
$this->assertTrue( $result );
|
|
}
|
|
|
|
public function test_should_return_true_when_author_matches_blocklist_keys() {
|
|
$author = 'Sideshow Mel';
|
|
$author_email = 'mel@example.com';
|
|
$author_url = 'http://example.com';
|
|
$comment = "Though we can't get him out. We'll do the next best thing.";
|
|
$author_ip = '192.168.0.1';
|
|
$user_agent = '';
|
|
|
|
update_option( 'blocklist_keys', "sideshow\nfoo" );
|
|
|
|
$result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
|
|
|
|
$this->assertTrue( $result );
|
|
}
|
|
|
|
public function test_should_return_true_when_url_matches_blocklist_keys() {
|
|
$author = 'Rainier Wolfcastle';
|
|
$author_email = 'rainier@wolfcastle.com';
|
|
$author_url = 'http://example.com';
|
|
$comment = 'We go on TV and sing, sing, sing.';
|
|
$author_ip = '192.168.0.1';
|
|
$user_agent = '';
|
|
|
|
update_option( 'blocklist_keys', "example\nfoo" );
|
|
|
|
$result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
|
|
|
|
$this->assertTrue( $result );
|
|
}
|
|
|
|
/**
|
|
* @ticket 37208
|
|
*/
|
|
public function test_should_return_true_when_link_matches_blocklist_keys() {
|
|
$author = 'Rainier Wolfcastle';
|
|
$author_email = 'rainier@wolfcastle.com';
|
|
$author_url = 'http://example.com';
|
|
$comment = 'We go on TV and sing, <a href="http://example.com/spam/>sing</a>, sing.';
|
|
$author_ip = '192.168.0.1';
|
|
$user_agent = '';
|
|
|
|
update_option( 'blocklist_keys', '/spam/' );
|
|
|
|
$result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
|
|
|
|
$this->assertTrue( $result );
|
|
}
|
|
|
|
public function test_should_return_false_when_no_match() {
|
|
$author = 'Krusty the Clown';
|
|
$author_email = 'krusty@example.com';
|
|
$author_url = 'http://example.com';
|
|
$comment = "And we're sending our love down the well.";
|
|
$author_ip = '192.168.0.1';
|
|
$user_agent = '';
|
|
|
|
update_option( 'blocklist_keys', "sideshow\nfoobar" );
|
|
|
|
$result = wp_blocklist_check( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
|
|
|
|
$this->assertFalse( $result );
|
|
}
|
|
}
|