Changeset 2381 for branches/0.9/bb-includes/wp-functions.php
- Timestamp:
- 11/24/2009 11:56:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9/bb-includes/wp-functions.php
r2380 r2381 9 9 /* Formatting */ 10 10 11 if ( !function_exists( 'clean_url' ) ) : // [WP 6182]11 if ( !function_exists( 'clean_url' ) ) : // [WP11615] 12 12 function clean_url( $url, $protocols = null, $context = 'display' ) { 13 13 $original_url = $url; 14 14 15 15 if ('' == $url) return $url; 16 $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@ ]|i', '', $url);17 $strip = array('%0d', '%0a' );18 $url = str_replace($strip, '', $url);16 $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url); 17 $strip = array('%0d', '%0a', '%0D', '%0A'); 18 $url = _deep_replace($strip, $url); 19 19 $url = str_replace(';//', '://', $url); 20 20 /* If the URL doesn't appear to contain a scheme, we 21 21 * presume it needs http:// appended (unless a relative 22 22 * link starting with / or a php file). 23 */23 */ 24 24 if ( strpos($url, ':') === false && 25 substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )25 substr( $url, 0, 1 ) != '/' && substr( $url, 0, 1 ) != '#' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) ) 26 26 $url = 'http://' . $url; 27 27 28 // Replace ampersands ony when displaying.29 if ( 'display' == $context ) 28 // Replace ampersands and single quotes only when displaying. 29 if ( 'display' == $context ) { 30 30 $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); 31 $url = str_replace( "'", ''', $url ); 32 } 31 33 32 34 if ( !is_array($protocols) ) … … 36 38 37 39 return apply_filters('clean_url', $url, $original_url, $context); 40 } 41 endif; 42 43 if ( !function_exists( '_deep_replace' ) ) : // [WP11615] 44 function _deep_replace($search, $subject){ 45 $found = true; 46 while($found) { 47 $found = false; 48 foreach( (array) $search as $val ) { 49 while(strpos($subject, $val) !== false) { 50 $found = true; 51 $subject = str_replace($val, '', $subject); 52 } 53 } 54 } 55 56 return $subject; 57 } 58 endif; 59 60 if ( !function_exists( 'esc_url' ) ) : // [WP11383] 61 function esc_url( $url, $protocols = null ) { 62 return clean_url( $url, $protocols, 'display' ); 38 63 } 39 64 endif;
Note: See TracChangeset
for help on using the changeset viewer.