remove scripts later in the queue

This commit is contained in:
Matthias Pfefferle 2023-02-20 21:18:03 +01:00
parent 9b642858f6
commit 72f12de96a
2 changed files with 4 additions and 4 deletions

View file

@ -197,9 +197,6 @@ class Shortcodes {
$content = \get_post_field( 'post_content', $post );
// replace script and style elements
$content = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content );
if ( 'yes' === $atts['apply_filters'] ) {
$content = \apply_filters( 'the_content', $content );
} else {
@ -208,6 +205,9 @@ class Shortcodes {
$content = wp_filter_content_tags( $content );
}
// replace script and style elements
$content = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content );
$content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) );
return $content;

View file

@ -10,7 +10,7 @@ class Test_Activitypub_Shortcodes extends WP_UnitTestCase {
$post->post_date = current_time( 'mysql' );
$post->post_date_gmt = current_time( 'mysql', 1 );
$post->post_title = 'Some title or other';
$post->post_content = '<script>test</script>hallo';
$post->post_content = '<script>test</script>hallo<script type="javascript">{"asdf": "qwerty"}</script><style></style>';
$post->post_status = 'publish';
$post->comment_status = 'closed';
$post->ping_status = 'closed';