Index: formatting.php
===================================================================
--- formatting.php	(revision 7502)
+++ formatting.php	(working copy)
@@ -830,8 +830,8 @@
 	if ( '' == $text ) {
 		$text = get_the_content('');
 		$text = apply_filters('the_content', $text);
+		$text = strip_all_tags($text);
 		$text = str_replace(']]>', ']]&gt;', $text);
-		$text = strip_tags($text);
 		$excerpt_length = 55;
 		$words = explode(' ', $text, $excerpt_length + 1);
 		if (count($words) > $excerpt_length) {
@@ -1406,4 +1406,24 @@
 	return $str;
 }
 
-?>
+/*
+ * strip_all_tags() - strip all html and php tags, improved version of strip_tags()
+ *  
+ * will remove all tags, including <script> and <style>
+ * 
+ * @param string $str The input string that needs stripping of tags
+ * @param string $keep Optional. Keep some tags. 
+ *  HTML comments (including the <!--more--> tag), <script>, <style> and php tags are always removed
+ */
+function strip_all_tags( $str, $keep = '' ) {
+
+	if ( strpos( $str, '<script' ) )
+		$str = preg_replace( '|<script[^>]*?>.*?</script>|si', '', $str );
+
+	if ( strpos( $str, '<style' ) )
+		$str = preg_replace( '|<style[^>]*?>.*?</style>|si', '', $str );
+
+	return strip_tags( $str, $keep );
+}
+
+?>
\ No newline at end of file

