From c05e9ea756bd523d16b3cfa9440e196bfba09f6c Mon Sep 17 00:00:00 2001
From: ryan
Date: Tue, 4 Jul 2006 23:16:04 +0000
Subject: [PATCH] Preserve newlines inside style and script tags. Props Nazgul.
fixes #2833
git-svn-id: http://svn.automattic.com/wordpress/trunk@3965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
---
wp-includes/formatting.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php
index bb6ea45632..cc5e76bdb5 100644
--- a/wp-includes/formatting.php
+++ b/wp-includes/formatting.php
@@ -70,7 +70,11 @@ function wpautop($pee, $br = 1) {
$pee = str_replace('
', '', $pee);
$pee = preg_replace('!\s*(?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "$1", $pee);
$pee = preg_replace('!(?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*
!', "$1", $pee);
- if ($br) $pee = preg_replace('|(?)\s*\n|', "
\n", $pee); // optionally make line breaks
+ if ($br) {
+ $pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "", "\\0")', $pee);
+ $pee = preg_replace('|(?)\s*\n|', "
\n", $pee); // optionally make line breaks
+ $pee = str_replace('', "\n", $pee);
+ }
$pee = preg_replace('!(?(?:table|thead|tfoot|caption|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*
!', "$1", $pee);
$pee = preg_replace('!
(\s*?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)!', '$1', $pee);
$pee = preg_replace('!()(.*?)!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '' ", $pee);