summaryrefslogtreecommitdiffstats
path: root/wp-inst/wp-includes/functions-formatting.php
diff options
context:
space:
mode:
authormatt <matt@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-05-15 03:19:56 +0000
committermatt <matt@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-05-15 03:19:56 +0000
commit034694eb53dd71a980745f5594509890fd761998 (patch)
treec85517e8af3fce163f1d183afdf7c9ac7094d84e /wp-inst/wp-includes/functions-formatting.php
parenta72266931b88c8fa300d2e29a69a2bb38a70654a (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.php32
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};)/', '&#038;$1', $curl);
+ $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&#038;$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};)/', '&#038;$1', $text);-
+ $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&#038;$1', $text);
$text = str_replace('<', '&lt;', $text);
$text = str_replace('>', '&gt;', $text);
- if ( $quotes ) {
+ if ( 'double' === $quotes ) {
+ $text = str_replace('"', '&quot;', $text);
+ } elseif ( 'single' === $quotes ) {
+ $text = str_replace("'", '&#039;', $text);
+ } elseif ( $quotes ) {
$text = str_replace('"', '&quot;', $text);
$text = str_replace("'", '&#039;', $text);
}
@@ -1001,10 +1005,7 @@ function ent2ncr($text) {
'&diams;' => '&#9830;'
);
- 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};)/', '&#038;$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};)/","&amp;" , strtr($myHTML, $translation_table));
+}
+
?>