Make WordPress Core


Ignore:
Timestamp:
11/28/2022 07:42:56 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Comments: Make moderated or disallowed key check case-insensitive for non-Latin words.

The check_comment() and wp_check_comment_disallowed_list() functions are expected to be case-insensitive, but that only worked for words using Latin script and consisting of ASCII characters.

This commit adds the Unicode flag to the regular expression used for the check in these functions, so that both pattern and subject can be treated as UTF-8 strings.

Reference: PHP Manual: Pattern Modifiers.

Follow-up to [984], [2075], [48121], [48575].

Props bonjour52, SergeyBiryukov.
Fixes #57207.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r54877 r54888  
    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;
     
    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 )
Note: See TracChangeset for help on using the changeset viewer.