Make WordPress Core

Opened 4 months ago

Closed 4 months ago

#64557 closed defect (bug) (fixed)

WP_Customize_Media_Control default webp

Reported by: buutqn's profile buutqn Owned by: westonruter's profile westonruter
Milestone: 7.0 Priority: normal
Severity: minor Version: 6.9
Component: Customize Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Class WP_Customize_Media_Control, in function to_json, ignores different number of characters for extensions, ignoring those extensions that has 4 characters.
https://github.com/WordPress/wordpress-develop/blob/6.9/src/wp-includes/customize/class-wp-customize-media-control.php#L95-L96

Line 95 will not return "webp" or "avif":

$ext  = substr( $this->setting->default, -3 );

Change History (7)

This ticket was mentioned in PR #10803 on WordPress/wordpress-develop by buutqn.


4 months ago
#1

  • Keywords has-patch added; needs-patch removed

Fix WP_Customize_Media_Control::to_json() extension validation.

Trac ticket: #64557

#2 @buutqn
4 months ago

Should we simplify?

$ext = pathinfo( $this->setting->default, PATHINFO_EXTENSION );

#3 @westonruter
4 months ago

  • Milestone changed from Awaiting Review to 7.0
  • Owner set to westonruter
  • Status changed from new to reviewing

Good catch. This certainly can be made more robust.

The use of substr() was introduced in r30309 (4175d8a). But the actual issue was introduced in r50810 (for #35725) to add WebP support and similarly in r57524 (for #51228) to add AVIF support, as these two file formats use 4-character file file extensions.

@westonruter commented on PR #10803:


4 months ago
#4

Note: In the future, it would be preferable to open a pull request to target trunk rather than the current release branch.

#7 @westonruter
4 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 61576:

Customize: Use wp_check_filetype() instead of substr() to extract file extension.

This fixes compatibility with image files that have 4-character extensions, such as .webp and .avif.

Follow-up to [57524], [50810], [30309].

Props buutqn, westonruter.
See #51228, #35725, #21483.
Fixes #64557.

Note: See TracTickets for help on using tickets.