Changeset 43467
- Timestamp:
- 07/17/2018 08:59:30 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r43245 r43467 3441 3441 ); 3442 3442 3443 /* translators: Name of a comment's author after being anonymized. */ 3443 3444 $anon_author = __( 'Anonymous' ); 3444 3445 $messages = array(); … … 3448 3449 $anonymized_comment['comment_agent'] = ''; 3449 3450 $anonymized_comment['comment_author'] = $anon_author; 3450 $anonymized_comment['comment_author_email'] = wp_privacy_anonymize_data( 'email', $comment->comment_author_email );3451 $anonymized_comment['comment_author_email'] = ''; 3451 3452 $anonymized_comment['comment_author_IP'] = wp_privacy_anonymize_data( 'ip', $comment->comment_author_IP ); 3452 $anonymized_comment['comment_author_url'] = wp_privacy_anonymize_data( 'url', $comment->comment_author_url );3453 $anonymized_comment['comment_author_url'] = ''; 3453 3454 $anonymized_comment['user_id'] = 0; 3454 3455 -
trunk/tests/phpunit/tests/comment.php
r43371 r43467 816 816 * The `wp_comments_personal_data_eraser()` function should erase user's comments. 817 817 * 818 * @group privacy 818 819 * @ticket 43442 819 820 */ … … 857 858 'user_id' => '0', // Anonymized. 858 859 'comment_author' => 'Anonymous', // Anonymized. 859 'comment_author_email' => ' deleted@site.invalid', // Anonymized.860 'comment_author_url' => ' https://site.invalid', // Anonymized.860 'comment_author_email' => '', // Anonymized. 861 'comment_author_url' => '', // Anonymized. 861 862 'comment_author_IP' => '192.168.0.0', // Anonymized. 862 863 'comment_date' => '2018-04-14 17:20:00', … … 872 873 * Testing the `wp_comments_personal_data_eraser()` function's output on an empty first page. 873 874 * 875 * @group privacy 874 876 * @ticket 43442 875 877 */ … … 890 892 * Testing the `wp_comments_personal_data_eraser()` function's output, for the non-empty first page. 891 893 * 894 * @group privacy 892 895 * @ticket 43442 893 896 */ … … 921 924 * Testing the `wp_comments_personal_data_eraser()` function's output, for an empty second page. 922 925 * 926 * @group privacy 923 927 * @ticket 43442 924 928 */ … … 952 956 * Testing the `wp_anonymize_comment` filter, to prevent comment anonymization. 953 957 * 958 * @group privacy 954 959 * @ticket 43442 955 960 */ … … 988 993 * Testing the `wp_anonymize_comment` filter, to prevent comment anonymization, with a custom message. 989 994 * 995 * @group privacy 990 996 * @ticket 43442 991 997 */ -
trunk/tests/phpunit/tests/functions/anonymization.php
r42971 r43467 3 3 * Test anonymization functions. 4 4 * 5 * @package WordPress 6 * 7 * @since 5.0.05 * @package WordPress\UnitTests 6 * 7 * @since 4.9.6 8 8 */ 9 9 … … 14 14 * @group privacy 15 15 * 16 * @since 5.0.016 * @since 4.9.6 17 17 */ 18 18 class Tests_Functions_Anonymization extends WP_UnitTestCase { … … 43 43 * Provide test cases for `test_wp_privacy_anonymize_ip()`. 44 44 * 45 * @since 5.0.0Moved from `Test_WP_Community_Events::data_get_unsafe_client_ip_anonymization()`.45 * @since 4.9.6 Moved from `Test_WP_Community_Events::data_get_unsafe_client_ip_anonymization()`. 46 46 * 47 47 * @return array { … … 213 213 */ 214 214 public function test_anonymize_email() { 215 $this->assert Equals( 'deleted@site.invalid', wp_privacy_anonymize_data( 'email', 'bar@example.com' ) );215 $this->assertSame( '', wp_privacy_anonymize_data( 'email', 'bar@example.com' ) ); 216 216 } 217 217 … … 220 220 */ 221 221 public function test_anonymize_url() { 222 $this->assert Equals( 'https://site.invalid', wp_privacy_anonymize_data( 'url', 'https://example.com/author/username' ) );222 $this->assertSame( '', wp_privacy_anonymize_data( 'url', 'https://example.com/author/username' ) ); 223 223 } 224 224 … … 245 245 $this->assertEquals( 'This content was deleted by the author.', wp_privacy_anonymize_data( 'longtext', $text ) ); 246 246 } 247 248 /** 249 * Test text anonymization when a filter is added. 250 * 251 * @ticket 44141 252 */ 253 public function test_anonymize_with_filter() { 254 add_filter( 'wp_privacy_anonymize_data', array( $this, 'filter_wp_privacy_anonymize_data' ), 10, 3 ); 255 $actual_url = wp_privacy_anonymize_data( 'url', 'https://example.com/author/username' ); 256 remove_filter( 'wp_privacy_anonymize_data', array( $this, 'filter_wp_privacy_anonymize_data' ), 10 ); 257 258 $this->assertSame( 'http://local.host/why-this-was-removed', $actual_url ); 259 } 260 261 /** 262 * Change the anonymized value for URLs. 263 * 264 * @since 4.9.8 265 * 266 * @param string $anonymous Anonymized data. 267 * @param string $type Type of the data. 268 * @param string $data Original data. 269 * @return string $anonymous Anonymized data. 270 */ 271 public function filter_wp_privacy_anonymize_data( $anonymous, $type, $data ) { 272 if ( 'url' === $type && 'example.com' === parse_url( $data, PHP_URL_HOST ) ) { 273 return 'http://local.host/why-this-was-removed'; 274 } 275 return $anonymous; 276 } 277 247 278 }
Note: See TracChangeset
for help on using the changeset viewer.