From 5f2832c56bc1380b6b44c5b9fee4260ffa17e52b Mon Sep 17 00:00:00 2001 From: Ryan Boren 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: https://develop.svn.wordpress.org/trunk@3965 602fd350-edb4-49c9-b593-d223f7449a82 --- 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*(]*>)!', "$1", $pee); $pee = preg_replace('!(]*>)\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('!(]*>)\s*
!', "$1", $pee); $pee = preg_replace('!
(\s*)!', '$1', $pee); $pee = preg_replace('!()(.*?)!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '' ", $pee);