Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#60610 closed enhancement (fixed)

Consider fixing user mistakes and/or adding unit tests for $preferred_ext in wp_mime_type_icon()

Reported by: sabernhardt Owned by: joedolson
Priority: normal Milestone: 6.6
Component: Media Version: 6.5
Severity: normal Keywords: has-patch has-unit-tests commit
Cc: Focuses:

Description

Follow-up to ticket:31352#comment:54

The $preferred_ext value for wp_mime_type_icon() begins with a period, and developers might miss that. The function could check the first character and add the dot if it does not exist there. The function also could ensure that the letters are lowercase.

For unit tests, the test_wp_mime_type_icon_video test in post/attachments.php checks the default $preferred_ext parameter value. Adding at least one more test with a specific $preferred_ext could help.

Change History (8)

#1 @joedolson
2 years ago

  • Milestone Awaiting Review6.6
  • Owner set to joedolson
  • Status newaccepted

This ticket was mentioned in Slack in #core-media by joedolson. View the logs.


2 years ago

#3 @oglekler
2 years ago

  • Keywords needs-patch needs-unit-tests added

This ticket was mentioned in PR #6592 on WordPress/wordpress-develop by @khokansardar.


2 years ago
#4

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed

…for it

Add $preferred_ext check in function wp_mime_type_icon with proper unit test cases.

Trac ticket: #60610

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


2 years ago

#6 @joedolson
2 years ago

  • Keywords commit added

#7 @joedolson
2 years ago

  • Resolutionfixed
  • Status acceptedclosed

In 58248:

Media: Protect mime type icon function from simple errors.

Handle $preferred_ext arguments that are passed with minor errors in formatting, such as incorrect casing or missing .. Add unit tests to verify that an omitted period on an otherwise correct extension is accepted. Follow up to [57687].

Props sabernhardt, joedolson, khokansardar.
Fixes #60610.

@joedolson commented on PR #6592:


2 years ago
#8

In r58248

Note: See TracTickets for help on using tickets.