diff options
| author | matt <matt@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-05-15 03:19:56 +0000 |
|---|---|---|
| committer | matt <matt@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-05-15 03:19:56 +0000 |
| commit | 034694eb53dd71a980745f5594509890fd761998 (patch) | |
| tree | c85517e8af3fce163f1d183afdf7c9ac7094d84e /wp-inst/wp-includes/functions-formatting.php | |
| parent | a72266931b88c8fa300d2e29a69a2bb38a70654a (diff) | |
Lots and lots of changes.
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@543 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-includes/functions-formatting.php')
| -rw-r--r-- | wp-inst/wp-includes/functions-formatting.php | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/wp-inst/wp-includes/functions-formatting.php b/wp-inst/wp-includes/functions-formatting.php index feae447..8b4f9da 100644 --- a/wp-inst/wp-includes/functions-formatting.php +++ b/wp-inst/wp-includes/functions-formatting.php @@ -41,7 +41,7 @@ function wptexturize($text) { } else { $next = true; } - $curl = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&$1', $curl); + $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&$1', $curl); $output .= $curl; } return $output; @@ -98,10 +98,14 @@ function seems_utf8($Str) { # by bmorel at ssi dot fr function wp_specialchars( $text, $quotes = 0 ) { // Like htmlspecialchars except don't double-encode HTML entities - $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&$1', $text);- + $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&$1', $text); $text = str_replace('<', '<', $text); $text = str_replace('>', '>', $text); - if ( $quotes ) { + if ( 'double' === $quotes ) { + $text = str_replace('"', '"', $text); + } elseif ( 'single' === $quotes ) { + $text = str_replace("'", ''', $text); + } elseif ( $quotes ) { $text = str_replace('"', '"', $text); $text = str_replace("'", ''', $text); } @@ -1001,10 +1005,7 @@ function ent2ncr($text) { '♦' => '♦' ); - foreach ($to_ncr as $entity => $ncr) { - $text = str_replace($entity, $ncr, $text); - } - return $text; + return str_replace( array_keys($to_ncr), array_values($to_ncr), $text ); } function wp_richedit_pre($text) { @@ -1022,4 +1023,21 @@ function wp_richedit_pre($text) { return apply_filters('richedit_pre', $output); } +function clean_url( $url ) { + if ('' == $url) return $url; + $url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $url); + $url = str_replace(';//', '://', $url); + $url = (!strstr($url, '://')) ? 'http://'.$url : $url; + $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); + return $url; +} + +// Borrowed from the PHP Manual user notes. Convert entities, while +// preserving already-encoded entities: +function htmlentities2($myHTML) { + $translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES); + $translation_table[chr(38)] = '&'; + return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($myHTML, $translation_table)); +} + ?> |
