Make WordPress Core

Opened 21 months ago

Last modified 21 months ago

#56433 new defect (bug)

invalid regex used in preg_replace

Reported by: chocofc1's profile chocofc1 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Formatting Keywords: reporter-feedback
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Found in /wp-includes/formatting.php line 5385

$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );

I tried this exactly as it is and it does nothing

Change History (2)

#1 @SergeyBiryukov
21 months ago

  • Description modified (diff)

#2 @SergeyBiryukov
21 months ago

  • Keywords reporter-feedback added

Hi there, welcome to WordPress Trac! Thanks for the ticket.

That regex is in the wp_strip_all_tags() function, and its purpose is to remove all script and style tags from the passed string, including their content.

There is a basic unit test for the function to make sure it works as expected, and it passes in the current builds. Introduced in [27042] / #25507.

Could you elaborate a bit more on what is the issue here? Does it still happen with all plugins disabled and a default theme (Twenty Twenty-Two) activated? Could you share the steps to reproduce it on a clean install?

Note: See TracTickets for help on using tickets.