Making WordPress.org


Ignore:
Timestamp:
04/15/2024 07:39:37 AM (15 months ago)
Author:
dd32
Message:

Plugin Directory: Readme Parser: When trimming sections, if invalid UTF8 data is encountered, trim it in a non-utf8 safe manner.

This avoids warnings and unexpected outputs from the function.

See #7477, [13236].

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php

    r13523 r13525  
    555555        if ( 'words' === $type ) {
    556556            // Split by whitespace, capturing it so we can put it back together.
    557             $pieces = preg_split( '/(\s+)/u', $desc, -1, PREG_SPLIT_DELIM_CAPTURE );
     557            $pieces = @preg_split( '/(\s+)/u', $desc, -1, PREG_SPLIT_DELIM_CAPTURE );
     558
     559            // In the event of an error (Likely invalid UTF8 data), perform the same split, this time in a non-UTF8 safe manner, as a fallback.
     560            if ( $pieces === false ) {
     561                $pieces = preg_split( '/(\s+)/', $desc, -1, PREG_SPLIT_DELIM_CAPTURE );
     562            }
    558563
    559564            $word_count_with_spaces = $length * 2;
Note: See TracChangeset for help on using the changeset viewer.