Make WordPress Core

Opened 4 years ago

Last modified 23 months ago

#56433 new defect (bug)

invalid regex used in preg_replace

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

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 (3)

#1 @SergeyBiryukov
4 years ago

  • Description modified (diff)

#2 @SergeyBiryukov
4 years 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?

This ticket was mentioned in ​Slack in #core-test by oglekler. ​View the logs.


23 months ago

Note: See TracTickets for help on using tickets.