Don't texturize things inside of script or style tags, fixes #2647

git-svn-id: http://svn.automattic.com/wordpress/trunk@4565 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2006-12-01 02:53:20 +00:00
parent d5e1cc7a6f
commit c6531fe271
1 changed files with 5 additions and 1 deletions

View File

@ -32,7 +32,7 @@ function wptexturize($text) {
// regular expressions // regular expressions
$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
} elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) { } elseif ( strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd') || strstr($curl, '<style') || strstr($curl, '<script') ) {
$next = false; $next = false;
} else { } else {
$next = true; $next = true;
@ -63,6 +63,9 @@ function wpautop($pee, $br = 1) {
$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
$pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
$pee = preg_replace( '|<p>(<div[^>]*>\s*)|', "$1<p>", $pee );
$pee = preg_replace('!<p>([^<]+)\s*?(</(?:div|address|form)[^>]*>)!', "<p>$1</p>$2", $pee);
$pee = preg_replace( '|<p>|', "$1<p>", $pee );
$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
$pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
$pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee); $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
@ -79,6 +82,7 @@ function wpautop($pee, $br = 1) {
if ( strstr( $pee, '<pre' ) ) if ( strstr( $pee, '<pre' ) )
$pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee); $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee);
$pee = preg_replace( "|\n</p>$|", '</p>', $pee ); $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
/**/
return $pee; return $pee;
} }