Skip to:
Content

bbPress.org

Changeset 7397


Ignore:
Timestamp:
02/18/2026 06:49:42 PM (5 weeks ago)
Author:
johnjamesjacoby
Message:

Common: Fix incorrect encoding in bbp_is_title_too_long().

This commit changes the way that Forum/Topic/Reply title lengths are calculated, away from 8bit for counting bytes to utf-8 for counting characters.

This change is necessary to allow unicode (multibyte) characters to be more accurately included in the overall length calculation, to better match the intention for this optional limitation.

In trunk, for 2.7.

Props r-a-y.

Fixes #3664.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/functions.php

    r7396 r7397  
    28052805 * Is a title longer that the maximum title length?
    28062806 *
    2807  * Uses mb_strlen() in `8bit` mode to treat strings as raw. This matches the
    2808  * behavior present in Comments, PHPMailer, RandomCompat, and others.
     2807 * Uses mb_strlen() in `utf-8` mode to treat strings as is. This differs from
     2808 * the behavior present in Comments, PHPMailer, RandomCompat, and others,
     2809 * because the database column used by titles (posts.post_title) is
     2810 * TEXT (characters) and not VARCHAR (bytes).
    28092811 *
    28102812 * @since 2.6.0 bbPress (r6783)
     
    28152817function bbp_is_title_too_long( $title = '' ) {
    28162818    $max    = bbp_get_title_max_length();
    2817     $len    = mb_strlen( $title, '8bit' );
     2819    $len    = mb_strlen( $title, 'utf-8' );
    28182820    $result = ( $len > $max );
    28192821
Note: See TracChangeset for help on using the changeset viewer.