Ticket #18268: esc_url-protocols-2.patch
| File esc_url-protocols-2.patch, 1.9 KB (added by , 15 years ago) |
|---|
-
formatting.php
2246 2246 2247 2247 if ( '' == $url ) 2248 2248 return $url; 2249 $url = preg_replace( '|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);2250 $strip = array( '%0d', '%0a', '%0D', '%0A');2251 $url = _deep_replace( $strip, $url);2252 $url = str_replace( ';//', '://', $url);2249 $url = preg_replace( '|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url ); 2250 $strip = array( '%0d', '%0a', '%0D', '%0A' ); 2251 $url = _deep_replace( $strip, $url ); 2252 $url = str_replace( ';//', '://', $url ); 2253 2253 /* If the URL doesn't appear to contain a scheme, we 2254 2254 * presume it needs http:// appended (unless a relative 2255 2255 * link starting with /, # or ? or a php file). 2256 2256 */ 2257 if ( strpos( $url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&2258 ! preg_match( '/^[a-z0-9-]+?\.php/i', $url) )2257 if ( strpos( $url, ':' ) === false && ! in_array( $url[0], array( '/', '#', '?' ) ) && 2258 ! preg_match( '/^[a-z0-9-]+?\.php/i', $url ) ) 2259 2259 $url = 'http://' . $url; 2260 2260 2261 2261 // Replace ampersands and single quotes only when displaying. … … 2265 2265 $url = str_replace( "'", ''', $url ); 2266 2266 } 2267 2267 2268 if ( ! is_array($protocols) )2269 $protocols = a rray ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn');2268 if ( ! is_array( $protocols ) ) 2269 $protocols = apply_filters( 'esc_url_protocols', array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'callto', 'tel', 'sms', 'fax', 'skype', 'git' ) ); 2270 2270 if ( wp_kses_bad_protocol( $url, $protocols ) != $url ) 2271 2271 return ''; 2272 2272 2273 return apply_filters( 'clean_url', $url, $original_url, $_context);2273 return apply_filters( 'clean_url', $url, $original_url, $_context ); 2274 2274 } 2275 2275 2276 2276 /**