Opened 6 weeks ago
Last modified 3 weeks ago
#9338 new defect (bug)
14.5.0: sanitize_utf8_filename() can call transliterator_transliterate() when ext-intl is unavailable
| Reported by: | lverane | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Core | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | lverane |
Description (last modified by )
Reproduction:
PHP 8.2
intl extension disabled
WordPress 7.0.2
BuddyPress 14.5.0
Upload avatar with UTF-8 filename
Cause:
In sanitize_utf8_filename() both instances of function_exists( 'wp_is_valid_utf8' ) ? wp_is_valid_utf8( $retval ) : seems_utf8( $retval ) should be wrapped in parentheses.
File: /wp-content/plugins/buddypress/bp-core/classes/class-bp-attachment.php
Lines 297 - 322
Change History (3)
#2
in reply to: ↑ 1
@
3 weeks ago
- Description modified (diff)
Replying to espellcaste:
@lverane I don't get it. What's exactly the problem? Is there an error you can share?
In sanitize_utf8_filename() both instances of function_exists( 'wp_is_valid_utf8' ) ? wp_is_valid_utf8( $retval ) : seems_utf8( $retval ) should be wrapped in parentheses.
What does that mean exactly?
I added the file path to the ticket description. The issue is that the current if statement
if (
function_exists( 'transliterator_transliterate' )
// wp_is_valid_utf8 is added in WP 6.9.
&& function_exists( 'wp_is_valid_utf8' ) ? wp_is_valid_utf8( $retval ) : seems_utf8( $retval )
) {
Will resolve as
(function_exists( 'transliterator_transliterate' ) && function_exists( 'wp_is_valid_utf8' )) ? wp_is_valid_utf8( $retval ) : seems_utf8( $retval )
Meaning if function_exists( 'transliterator_transliterate' ) is false and seems_utf8( $retval ) is true transliterator_transliterate() is still called. The fix is to add parentheses around the second evaluation:
function_exists( 'transliterator_transliterate' ) && (function_exists( 'wp_is_valid_utf8' ) ? wp_is_valid_utf8( $retval ) : seems_utf8( $retval ))
Same issue/solution for function_exists( 'iconv' ) on the else statement.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
@lverane I don't get it. What's exactly the problem? Is there an error you can share?
What does that mean exactly?