Show
Ignore:
Timestamp:
10/03/07 16:17:54 (1 year ago)
Author:
ryan
Message:

Add sanitize_url. Don't convert ampersands in URLs when saving to DB. fixes #4411 for 2.3

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.3/wp-includes/formatting.php

    r6150 r6183  
    10881088} 
    10891089 
    1090 function clean_url( $url, $protocols = null ) { 
     1090function clean_url( $url, $protocols = null, $context = 'display' ) { 
    10911091    $original_url = $url; 
    10921092 
     
    11041104        $url = 'http://' . $url; 
    11051105 
    1106     $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); 
     1106    // Replace ampersands ony when displaying. 
     1107    if ( 'display' == $context ) 
     1108        $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); 
     1109 
    11071110    if ( !is_array($protocols) ) 
    11081111        $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'); 
     
    11101113        return ''; 
    11111114 
    1112     return apply_filters('clean_url', $url, $original_url); 
     1115    return apply_filters('clean_url', $url, $original_url, $context); 
     1116
     1117 
     1118function sanitize_url( $url, $protocols = null ) { 
     1119    return clean_url( $url, $protocols, 'db'); 
    11131120} 
    11141121