Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#60823 closed defect (bug) (fixed)

Font Library: `mb_strtolower()` throws fatal without the optional `mbstring` PHP extension installed.

Reported by: peterwilsoncc Owned by: swissspidy
Priority: normal Milestone: 6.5
Component: Editor Version:
Severity: normal Keywords: has-patch commit fixed-major dev-reviewed
Cc: Focuses:

Description

WP_Font_Utils::get_font_face_slug() method includes an unconditional call to the function mb_strtolower().

As the mbstring PHP package is optional this should be wrapped by a function_exists() check and fall back to strtolower() if the function is not available.

  1. Visit https://playground.wordpress.net/?wp=nightly
  2. Click Edit Site in the toolbar
  3. Proceed to open the Font Library Model via the styles editor
  4. Open the browser console
  5. Upload a font file (that playground doesn't upload doesn't matter)
  6. Observe the fatal error shown in the console:
PHP Fatal error:  Uncaught Error: Call to undefined function mb_strtolower() in /wordpress/wp-includes/fonts/class-wp-font-utils.php

Change History (9)

#1 @jrf
2 years ago

Related: #55603

Last edited 2 years ago by SergeyBiryukov (previous) (diff)

This ticket was mentioned in Slack in #core-editor by peterwilsoncc. View the logs.


2 years ago

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


2 years ago
#3

  • Keywords has-patch added

Font Library: mb_strtolower() throws fatal without the optional mbstring PHP extension installed.

Trac ticket: https://core.trac.wordpress.org/ticket/60823

Reported by @peterwilsoncc

#4 @swissspidy
2 years ago

  • Focuses coding-standards removed
  • Keywords commit dev-feedback added

#5 @swissspidy
2 years ago

  • Owner set to swissspidy
  • Resolutionfixed
  • Status newclosed

In 57865:

Editor: Check if mb_strtolower exists before using it in the font library.

Prevents an error when uploading fonts on certain systems, because the mbstring extension can be missing and thus the function may not be available.

Props mujuonly, swissspidy, peterwilsoncc.
Fixes #60823.
See #55603.

#7 @swissspidy
2 years ago

  • Keywords fixed-major added
  • Resolution fixed
  • Status closedreopened

#8 @jorbin
2 years ago

  • Keywords dev-reviewed added; dev-feedback removed

I've reviewed and tested. [57865] looks good for backport to the 6.5 branch.

#9 @swissspidy
2 years ago

  • Resolutionfixed
  • Status reopenedclosed

In 57869:

Editor: Check if mb_strtolower exists before using it in the font library.

Prevents an error when uploading fonts on certain systems, because the mbstring extension can be missing and thus the function may not be available.

Reviewed by jorbin.
Merges [57865] to the to the 6.5 branch.

Props mujuonly, swissspidy, peterwilsoncc.
Fixes #60823.
See #55603.

Note: See TracTickets for help on using tickets.