Make WordPress Core

Ticket #12868: 12868-5.diff

File 12868-5.diff, 2.5 KB (added by blepoxp, 15 years ago)

Hey Aaron, That worked on my system... though I realized we were having the same problem with the admin email as well. An error was being reported, but the option was getting updated anyway. Here is your diff updated to prevent emails from being updated if its not formatted correctly.

  • formatting.php

     
    23592359        switch ($option) {
    23602360                case 'admin_email':
    23612361                        $value = sanitize_email($value);
    2362                         if ( !$value && function_exists('add_settings_error') )
     2362                        if ( !$value && function_exists('add_settings_error') ){
     2363                                $value = get_option( $option ); // Resets option to stored val in case of invalid email
    23632364                                add_settings_error('admin_email', 'invalid_admin_email', __('The email address submitted was not in the right format. Please enter a valid email address.'));
     2365                        }
    23642366                        break;
    23652367
    23662368                case 'thumbnail_size_w':
     
    24342436                        $value = preg_replace('/[^0-9:.-]/', '', $value); // strips slashes
    24352437                        break;
    24362438
    2437                 case 'siteurl':
    2438                 case 'home':
    2439                         $value = esc_url_raw($value);
    2440                         break;
     2439                case 'siteurl':
     2440                        $value = esc_url_raw($value);
     2441                        if ( !is_url( $value ) )
     2442                        {
     2443                                $value = get_option( $option ); // Resets option to stored val in case of empty
     2444                                if( function_exists('add_settings_error') )
     2445                                        add_settings_error('siteurl', 'invalid_siteurl', __('The WordPress address you submitted was not in the right format. Please enter a valid URL.'));
     2446                        }
     2447                        break;
     2448                case 'home':
     2449                        $value = esc_url_raw($value);
     2450                        if ( !is_url( $value ) )
     2451                        {
     2452                                $value = get_option( $option ); // Resets option to stored val in case of empty
     2453                                if( function_exists('add_settings_error') )
     2454                                        add_settings_error('home', 'invalid_home', __('The Site address you submitted was not in the right format. Please enter a valid URL.'));
     2455                        }
     2456                        break;
    24412457                default :
    24422458                        $value = apply_filters("sanitize_option_{$option}", $value, $option);
    24432459                        break;
  • pluggable.php

     
    17671767        return $r;
    17681768}
    17691769endif;
     1770
     1771if( !function_exists('is_url') )
     1772{
     1773        /**
     1774         * Provides minimal validation that a string looks like a URL verifying only that it begins with http or https
     1775         * Note that strings without dots (i.e. localhost) are considered valid RFC domain names so validation does
     1776         * not look for .com, .net, etc
     1777         *
     1778         * @since 3.0
     1779         * @param string $url A URL to be validated.
     1780         * @return boolean
     1781        */
     1782        function is_url( $url )
     1783        {
     1784                preg_match( '#http(s?)://(.+)#i', $url, $matches );
     1785                if( empty( $matches ) )
     1786                        return false;
     1787                       
     1788                return true;
     1789        }
     1790}
     1791 No newline at end of file