Changeset 5 for trunk/bb-includes/formatting-functions.php
- Timestamp:
- 12/27/2004 11:22:22 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/bb-includes/formatting-functions.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bb-includes/formatting-functions.php
r4 r5 18 18 } 19 19 20 function bb_autop($pee, $br = 1) { 20 function bb_autop($pee, $br = 1) { // Reduced to be faster 21 21 $pee = $pee . "\n"; // just to make things a little easier, pad the end 22 22 $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee); 23 23 // Space things out a little 24 $pee = preg_replace('!(<(?: table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|math|p|h[1-6])[^>]*>)!', "\n$1", $pee);25 $pee = preg_replace('!(</(?: table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|math|p|h[1-6])>)!', "$1\n", $pee);24 $pee = preg_replace('!(<(?:ul|ol|li|pre|blockquote|p|h[1-6])[^>]*>)!', "\n$1", $pee); 25 $pee = preg_replace('!(</(?:ul|ol|li|pre|blockquote|p|h[1-6])>)!', "$1\n", $pee); 26 26 $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines 27 27 $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates 28 28 $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "\t<p>$1</p>\n", $pee); // make paragraphs, including one at the end 29 29 $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace 30 $pee = preg_replace('!<p>\s*(</?(?: table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag30 $pee = preg_replace('!<p>\s*(</?(?:ul|ol|li|pre|blockquote|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag 31 31 $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists 32 32 $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee); 33 33 $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee); 34 $pee = preg_replace('!<p>\s*(</?(?: table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|math|p|h[1-6])[^>]*>)!', "$1", $pee);35 $pee = preg_replace('!(</?(?: table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee);34 $pee = preg_replace('!<p>\s*(</?(?:ul|ol|li|pre|blockquote|p|h[1-6])[^>]*>)!', "$1", $pee); 35 $pee = preg_replace('!(</?(?:ul|ol|li|pre|blockquote|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); 36 36 if ($br) $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks 37 $pee = preg_replace('!(</?(?: table|thead|tfoot|caption|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|math|p|h[1-6])[^>]*>)\s*<br />!', "$1", $pee);37 $pee = preg_replace('!(</?(?:ul|ol|li|pre|blockquote|p|h[1-6])[^>]*>)\s*<br />!', "$1", $pee); 38 38 $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)!', '$1', $pee); 39 39 $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . clean_pre('$2') . '</pre>' ", $pee); … … 42 42 } 43 43 function encodeit($text) { 44 $text = stripslashes($text); 45 $text = preg_replace("|\n+|", "\n", $text); 46 $text = nl2br($text); 47 return $text; 44 $text = stripslashes($text); // because it's a regex callback 45 $text = htmlspecialchars($text, ENT_QUOTES); 46 $text = preg_replace("|\n+|", "\n", $text); 47 $text = nl2br($text); 48 return $text; 48 49 } 49 50 … … 61 62 $text = preg_replace('|<(/?ul)>|', '<$1>', $text); 62 63 $text = preg_replace('|<(/?li)>|', '<$1>', $text); 63 $text = preg_replace('|<(/?blockquote )>|', '<$1>', $text);64 $text = preg_replace('|<(/?blockquote.*?)>|', '<$1>', $text); 64 65 $text = preg_replace('|<(/?code)>|', '<$1>', $text); 66 67 $text = preg_replace("|`(.*?)`|se", "'<code>' . encodeit('$1') . '</code>'", $text); 68 65 69 return $text; 66 70 } 67 71 68 function wp_filter_kses($data) {72 function bb_filter_kses($data) { 69 73 $allowedtags = array( 70 74 'a' => array( … … 86 90 return wp_kses($data, $allowedtags); 87 91 } 92 93 function user_sanitize( $text ) { 94 $text = preg_replace('/[^a-z0-9_-]/i', '', $text); 95 return $text; 96 } 88 97 ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)