From 42ac7cf5e01ed193e95cd8da29e74c7db09b96fc Mon Sep 17 00:00:00 2001 From: Takshil Kunadia Date: Wed, 24 Sep 2025 11:46:09 +0530 Subject: [PATCH] fix: removing scripts and styles --- includes/class-content.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/class-content.php b/includes/class-content.php index f431dd7..33dc633 100644 --- a/includes/class-content.php +++ b/includes/class-content.php @@ -30,6 +30,9 @@ public static function get_republishable_content( $content, $post_id = false, $e // Remove comments from the content. (Lookin' at you, Gutenberg.) $content = preg_replace( '//i', ' ', $content ); + // Remove scripts from the content. + $content = preg_replace( '@]*?>.*?@si', '', $content ); + /** * What tags do we want to keep in the embed? * Not things from our server. @@ -201,6 +204,7 @@ private static function convert_html_to_plain_text( $html_content ) { $html_content = preg_replace( '/]*>(.*?)<\/h[1-6]>/is', "\n$1\n\n", $html_content ); $html_content = preg_replace( '/]*>(.*?)<\/p>/is', "$1\n\n", $html_content ); $html_content = preg_replace( '//i', "\n", $html_content ); + $html_content = preg_replace( '/]*?>.*?<\/style>/si', '', $html_content ); // ul to bullet points $html_content = preg_replace_callback(