Make WordPress Core

Ticket #40353: 40353.2.patch

File 40353.2.patch, 1.7 KB (added by shulard, 8 years ago)

Validate URL using parse_url and create a new is_wordpress_url function.

  • src/wp-includes/formatting.php

    diff --git c/src/wp-includes/formatting.php w/src/wp-includes/formatting.php
    index 80e1545caf..b908aa3a92 100644
    c w function is_email( $email, $deprecated = false ) { 
    29482948}
    29492949
    29502950/**
     2951 * Verifies that an URL is valid wordpress one.
     2952 *
     2953 * @since 0.71
     2954 *
     2955 * @param string $url URL to verify
     2956 * @return string|bool Either false or the valid url.
     2957 */
     2958function is_wordpress_url( $url ) {
     2959        $parsed = parse_url($url, PHP_URL_SCHEME);
     2960        if (false === $parsed) {
     2961                return apply_filters( 'is_wordpress_url', false, $url, 'invalid_url' );
     2962        }
     2963
     2964        if (null === $parsed || ($parsed !== 'http' && $parsed !== 'https')) {
     2965                return apply_filters( 'is_wordpress_url', false, $url, 'invalid_scheme' );
     2966        }
     2967
     2968        return apply_filters( 'is_wordpress_url', $url, $url, null );
     2969}
     2970
     2971/**
    29512972 * Convert to ASCII from email subjects.
    29522973 *
    29532974 * @since 1.2.0
    function sanitize_option( $option, $value ) { 
    41594180                        if ( is_wp_error( $value ) ) {
    41604181                                $error = $value->get_error_message();
    41614182                        } else {
    4162                                 if ( preg_match( '#http(s?)://(.+)#i', $value ) ) {
     4183                                if ( is_wordpress_url($value) ) {
    41634184                                        $value = esc_url_raw( $value );
    41644185                                } else {
    41654186                                        $error = __( 'The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.' );
    function sanitize_option( $option, $value ) { 
    41724193                        if ( is_wp_error( $value ) ) {
    41734194                                $error = $value->get_error_message();
    41744195                        } else {
    4175                                 if ( preg_match( '#http(s?)://(.+)#i', $value ) ) {
     4196                                if ( is_wordpress_url($value) ) {
    41764197                                        $value = esc_url_raw( $value );
    41774198                                } else {
    41784199                                        $error = __( 'The Site address you entered did not appear to be a valid URL. Please enter a valid URL.' );