Ticket #4411: clean_url.diff

File clean_url.diff, 1.7 KB (added by ryan, 5 years ago)
  • wp-includes/formatting.php

     
    10751075        return apply_filters('richedit_pre', $output); 
    10761076} 
    10771077 
    1078 function clean_url( $url, $protocols = null ) { 
     1078function clean_url( $url, $protocols = null, $context = 'display' ) { 
    10791079        if ('' == $url) return $url; 
    10801080        $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%]|i', '', $url); 
    10811081        $strip = array('%0d', '%0a'); 
     
    10851085        if ( strpos($url, '://') === false && 
    10861086                substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) ) 
    10871087                $url = 'http://' . $url; 
    1088          
    1089         $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); 
     1088 
     1089        if ( 'display' == $context ) 
     1090                $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url); 
    10901091        if ( !is_array($protocols) ) 
    10911092                $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet');  
    10921093        if ( wp_kses_bad_protocol( $url, $protocols ) != $url ) 
  • wp-includes/widgets.php

     
    872872        $options = $newoptions = get_option('widget_rss'); 
    873873        if ( $_POST["rss-submit-$number"] ) { 
    874874                $newoptions[$number]['items'] = (int) $_POST["rss-items-$number"]; 
    875                 $url = clean_url(strip_tags(stripslashes($_POST["rss-url-$number"]))); 
     875                $url = clean_url(strip_tags(stripslashes($_POST["rss-url-$number"])), '', 'save'); 
    876876                $newoptions[$number]['title'] = trim(strip_tags(stripslashes($_POST["rss-title-$number"]))); 
    877877                if ( $url !== $options[$number]['url'] ) { 
    878878                        require_once(ABSPATH . WPINC . '/rss.php');