From 6a0251847b6f742fa9e140209ead9a1f4ac73bef Mon Sep 17 00:00:00 2001
From: Andrew Ozz
Date: Wed, 5 Feb 2014 00:45:53 +0000
Subject: [PATCH] Consolidate handling of ', $pee );
+ $pee = preg_replace( '%\s*(?(?:param|embed)[^>]*>)\s*%', '$1', $pee );
}
+
+ if ( strpos( $pee, '\]]*[>\]])\s*%', '$1', $pee );
+ $pee = preg_replace( '%\s*([<\[]/(?:audio|video)[>\]])%', '$1', $pee );
+ $pee = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $pee );
+ }
+
$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
// make paragraphs, including one at the end
$pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY);
$pee = '';
- foreach ( $pees as $tinkle )
+
+ foreach ( $pees as $tinkle ) {
$pee .= '' . trim($tinkle, "\n") . "
\n";
+ }
+
$pee = preg_replace('|\s*
|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
$pee = preg_replace('!([^<]+)(div|address|form)>!', "
$1
$2>", $pee);
$pee = preg_replace('!\s*(?' . $allblocks . '[^>]*>)\s*
!', "$1", $pee); // don't pee all over a tag
@@ -256,11 +270,13 @@ function wpautop($pee, $br = true) {
$pee = str_replace('
', '', $pee);
$pee = preg_replace('!\s*(?' . $allblocks . '[^>]*>)!', "$1", $pee);
$pee = preg_replace('!(?' . $allblocks . '[^>]*>)\s*
!', "$1", $pee);
+
if ( $br ) {
$pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee);
$pee = preg_replace('|(?)\s*\n|', "
\n", $pee); // optionally make line breaks
$pee = str_replace('', "\n", $pee);
}
+
$pee = preg_replace('!(?' . $allblocks . '[^>]*>)\s*
!', "$1", $pee);
$pee = preg_replace('!
(\s*?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
$pee = preg_replace( "|\n$|", '', $pee );
diff --git a/tests/phpunit/tests/formatting/Autop.php b/tests/phpunit/tests/formatting/Autop.php
index 7cd324f985..d2f78bc17e 100644
--- a/tests/phpunit/tests/formatting/Autop.php
+++ b/tests/phpunit/tests/formatting/Autop.php
@@ -98,4 +98,169 @@ PS. Not yet subscribed for update notifications?
Password: ';
$this->assertEquals( "$str
", trim( wpautop( $str ) ) );
}
+
+ /**
+ * wpautop() Should not add and
around and