WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/18/2009 04:00:33 PM (12 years ago)
Author:
markjaquith
Message:

Deprecate sanitize_url() and clean_url() in favor of esc_url_raw() and esc_url()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r11380 r11383  
    11501150function _make_url_clickable_cb($matches) {
    11511151    $url = $matches[2];
    1152     $url = clean_url($url);
     1152    $url = esc_url($url);
    11531153    if ( empty($url) )
    11541154        return $matches[0];
     
    11721172    $dest = $matches[2];
    11731173    $dest = 'http://' . $dest;
    1174     $dest = clean_url($dest);
     1174    $dest = esc_url($dest);
    11751175    if ( empty($dest) )
    11761176        return $matches[0];
     
    19891989 *
    19901990 * A number of characters are removed from the URL. If the URL is for displaying
    1991  * (the default behaviour) amperstands are also replaced. The 'clean_url' filter
     1991 * (the default behaviour) amperstands are also replaced. The 'esc_url' filter
    19921992 * is applied to the returned cleaned URL.
    19931993 *
     
    20332033
    20342034/**
    2035  * Performs clean_url() for database usage.
    2036  *
    2037  * @see clean_url()
     2035 * Checks and cleans a URL.
     2036 *
     2037 * A number of characters are removed from the URL. If the URL is for displaying
     2038 * (the default behaviour) amperstands are also replaced. The 'esc_url' filter
     2039 * is applied to the returned cleaned URL.
     2040 *
     2041 * @since 2.8.0
     2042 * @uses esc_url()
     2043 * @uses wp_kses_bad_protocol() To only permit protocols in the URL set
     2044 *      via $protocols or the common ones set in the function.
     2045 *
     2046 * @param string $url The URL to be cleaned.
     2047 * @param array $protocols Optional. An array of acceptable protocols.
     2048 *      Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' if not set.
     2049 * @return string The cleaned $url after the 'cleaned_url' filter is applied.
     2050 */
     2051function esc_url( $url, $protocols = null ) {
     2052    return clean_url( $url, $protocols, 'display' );
     2053}
     2054
     2055/**
     2056 * Performs esc_url() for database usage.
     2057 *
     2058 * @see esc_url()
     2059 * @see esc_url()
     2060 *
     2061 * @since 2.8.0
     2062 *
     2063 * @param string $url The URL to be cleaned.
     2064 * @param array $protocols An array of acceptable protocols.
     2065 * @return string The cleaned URL.
     2066 */
     2067function esc_url_raw( $url, $protocols = null ) {
     2068    return clean_url( $url, $protocols, 'db' );
     2069}
     2070
     2071/**
     2072 * Performs esc_url() for database or redirect usage.
     2073 *
     2074 * @see esc_url()
     2075 * @deprecated 2.8.0
    20382076 *
    20392077 * @since 2.3.1
     
    22812319        case 'home':
    22822320            $value = stripslashes($value);
    2283             $value = clean_url($value);
     2321            $value = esc_url($value);
    22842322            break;
    22852323        default :
Note: See TracChangeset for help on using the changeset viewer.