Make WordPress Core

Opened 8 months ago

Closed 8 months ago

#64557 closed defect (bug) (fixed)

WP_Customize_Media_Control default webp

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

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.


8 months ago
#1

  • Keywords has-patch added; needs-patch removed

Fix WP_Customize_Media_Control::to_json() extension validation.

Trac ticket: #64557

#2 @buutqn
8 months ago

Should we simplify?

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

#3 @westonruter
8 months ago

  • Milestone Awaiting Review → 7.0
  • Owner set to westonruter
  • Status new → 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:


8 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
8 months ago

  • Resolution → fixed
  • Status reviewing → 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.