Make WordPress Core

Ticket #57207: 57207.2.diff

File 57207.2.diff, 3.2 KB (added by SergeyBiryukov, 3 years ago)
  • src/wp-includes/comment.php

     
    9797                         * Check the comment fields for moderation keywords. If any are found,
    9898                         * fail the check for the given field by returning false.
    9999                         */
    100                         $pattern = "#$word#i";
     100                        $pattern = "#$word#iu";
    101101                        if ( preg_match( $pattern, $author ) ) {
    102102                                return false;
    103103                        }
     
    13571357                // in the spam words don't break things:
    13581358                $word = preg_quote( $word, '#' );
    13591359
    1360                 $pattern = "#$word#i";
     1360                $pattern = "#$word#iu";
    13611361                if ( preg_match( $pattern, $author )
    13621362                        || preg_match( $pattern, $email )
    13631363                        || preg_match( $pattern, $url )
  • tests/phpunit/tests/comment/checkComment.php

     
    7070                $this->assertTrue( $results );
    7171        }
    7272
    73         public function test_should_return_false_when_content_matches_moderation_key() {
     73        public function test_should_return_false_when_content_matches_moderation_keys() {
    7474                update_option( 'comment_previously_approved', 0 );
    7575
    7676                $author       = 'WendytheBuilder';
     
    8686                $this->assertFalse( $results );
    8787        }
    8888
     89        /**
     90         * @ticket 57207
     91         */
     92        public function test_should_return_false_when_content_with_non_latin_words_matches_moderation_keys() {
     93                update_option( 'comment_previously_approved', 0 );
     94
     95                $author       = 'Setup';
     96                $author_email = 'setup@example.com';
     97                $author_url   = 'http://example.com';
     98                $comment      = 'Установка';
     99                $author_ip    = '192.168.0.1';
     100                $user_agent   = '';
     101                $comment_type = '';
     102
     103                update_option( 'moderation_keys', "установка\nfoo" );
     104                $results = check_comment( $author, $author_email, $author_url, $comment, $author_ip, $user_agent, $comment_type );
     105                $this->assertFalse( $results );
     106        }
     107
    89108        public function test_should_return_true_when_content_does_not_match_moderation_keys() {
    90109                update_option( 'comment_previously_approved', 0 );
    91110
  • tests/phpunit/tests/comment/wpCheckCommentDisallowedList.php

     
    4040                $this->assertTrue( $result );
    4141        }
    4242
     43        /**
     44         * @ticket 57207
     45         */
     46        public function test_should_return_true_when_content_with_non_latin_words_matches_disallowed_keys() {
     47                $author       = 'Setup';
     48                $author_email = 'setup@example.com';
     49                $author_url   = 'http://example.com';
     50                $comment      = 'Установка';
     51                $author_ip    = '192.168.0.1';
     52                $user_agent   = '';
     53
     54                update_option( 'disallowed_keys', "установка\nfoo" );
     55
     56                $result = wp_check_comment_disallowed_list( $author, $author_email, $author_url, $comment, $author_ip, $user_agent );
     57
     58                $this->assertTrue( $result );
     59        }
     60
    4361        public function test_should_return_true_when_author_matches_disallowed_keys() {
    4462                $author       = 'Sideshow Mel';
    4563                $author_email = 'mel@example.com';