Ticket #5604: formatting.php.5604.patch

File formatting.php.5604.patch, 1.0 kB (added by sunburntkamel, 8 months ago)

patch wp_trim_excerpt to strip style and script tags completely

  • C:/Users/sbk/workspace/Wordpress

    old new  
    816816                $text = get_the_content(''); 
    817817                $text = apply_filters('the_content', $text); 
    818818                $text = str_replace(']]>', ']]>', $text); 
     819        $search = array('@<script[^>]*?>.*?</script>@si',  // Strip out javascript 
     820                        '@<style[^>]*?>.*?</style>@siU',    // Strip style tags p$ 
     821                        '@<[\/\!]*?[^<>]*?>@si',            // Strip out HTML tags 
     822                        '@<![\s\S]*?--[ \t\n\r]*>@'        // Strip multi-line co$ 
     823                ); 
     824        $text = preg_replace($search, '', $text);                
    819825                $text = strip_tags($text); 
    820826                $excerpt_length = 55; 
    821827                $words = explode(' ', $text, $excerpt_length + 1);