diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-23 18:28:40 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-23 18:28:40 +0000 |
commit | 87bb8cd69cc593fe6bed330fb1791eac9df87167 (patch) | |
tree | 6b2ad252df89d2a1863198fd44b321b59e42ef54 /wp-includes/formatting.php | |
parent | 0cbda3349a2571904ea063fdd73e018299919589 (diff) | |
download | wordpress-mu-87bb8cd69cc593fe6bed330fb1791eac9df87167.tar.gz wordpress-mu-87bb8cd69cc593fe6bed330fb1791eac9df87167.tar.xz wordpress-mu-87bb8cd69cc593fe6bed330fb1791eac9df87167.zip |
Merge with WordPress, rev 6285 and untested
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1125 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/formatting.php')
-rw-r--r-- | wp-includes/formatting.php | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index a58aa88..2c95dbe 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1087,7 +1087,7 @@ function wp_richedit_pre($text) { return apply_filters('richedit_pre', $output); } -function clean_url( $url, $protocols = null ) { +function clean_url( $url, $protocols = null, $context = 'display' ) { $original_url = $url; if ('' == $url) return $url; @@ -1103,13 +1103,20 @@ function clean_url( $url, $protocols = null ) { substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) ) $url = 'http://' . $url; - $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); + // Replace ampersands ony when displaying. + if ( 'display' == $context ) + $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); + if ( !is_array($protocols) ) $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'); if ( wp_kses_bad_protocol( $url, $protocols ) != $url ) return ''; - return apply_filters('clean_url', $url, $original_url); + return apply_filters('clean_url', $url, $original_url, $context); +} + +function sanitize_url( $url, $protocols = null ) { + return clean_url( $url, $protocols, 'db'); } // Borrowed from the PHP Manual user notes. Convert entities, while |