Make WordPress Core

Ticket #12868: 12868-4.diff

File 12868-4.diff, 2.0 KB (added by technosailor, 15 years ago)

Ok, try this

  • Users/aaron/Sites/wp-includes/formatting.php

     
    24352435                        break;
    24362436
    24372437                case 'siteurl':
     2438                        $value = esc_url_raw($value);
     2439                        if ( !is_url( $value ) )
     2440                        {
     2441                                $value = get_option( $option ); // Resets option to stored val in case of empty
     2442                                if( function_exists('add_settings_error') )
     2443                                        add_settings_error('siteurl', 'invalid_siteurl', __('The WordPress address you submitted was not in the right format. Please enter a valid URL.'));
     2444                        }
     2445                        break;
    24382446                case 'home':
    24392447                        $value = esc_url_raw($value);
     2448                        if ( !is_url( $value ) )
     2449                        {
     2450                                $value = get_option( $option ); // Resets option to stored val in case of empty
     2451                                if( function_exists('add_settings_error') )
     2452                                        add_settings_error('home', 'invalid_home', __('The Site address you submitted was not in the right format. Please enter a valid URL.'));
     2453                        }
    24402454                        break;
    24412455                default :
    24422456                        $value = apply_filters("sanitize_option_{$option}", $value, $option);
  • Users/aaron/Sites/wp-includes/pluggable.php

     
    17491749        return $r;
    17501750}
    17511751endif;
     1752
     1753if( !function_exists('is_url') )
     1754{
     1755        /**
     1756         * Provides minimal validation that a string looks like a URL verifying only that it begins with http or https
     1757         * Note that strings without dots (i.e. localhost) are considered valid RFC domain names so validation does
     1758         * not look for .com, .net, etc
     1759         *
     1760         * @since 3.0
     1761         * @param string $url A URL to be validated.
     1762         * @return boolean
     1763        */
     1764        function is_url( $url )
     1765        {
     1766                preg_match( '#http(s?)://(.+)#i', $url, $matches );
     1767                if( empty( $matches ) )
     1768                        return false;
     1769                       
     1770                return true;
     1771        }
     1772}
     1773 No newline at end of file