Make WordPress Core

Ticket #13839: 13839.5.diff

File 13839.5.diff, 3.0 KB (added by SergeyBiryukov, 13 years ago)
  • wp-admin/setup-config.php

     
    5151
    5252require_once(ABSPATH . WPINC . '/compat.php');
    5353require_once(ABSPATH . WPINC . '/class-wp-error.php');
     54require_once(ABSPATH . WPINC . '/formatting.php');
    5455
    5556if ( ! file_exists( ABSPATH . 'wp-config-sample.php' ) )
    5657        wp_die( __( 'Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.' ) );
     
    152153        break;
    153154
    154155        case 2:
    155         $dbname  = trim($_POST['dbname']);
    156         $uname   = trim($_POST['uname']);
    157         $passwrd = trim($_POST['pwd']);
    158         $dbhost  = trim($_POST['dbhost']);
    159         $prefix  = trim($_POST['prefix']);
    160         if ( empty($prefix) )
    161                 $prefix = 'wp_';
     156        wp_magic_quotes();
    162157
     158        $dbname  = trim( stripslashes( $_POST['dbname'] ) );
     159        $uname   = trim( stripslashes( $_POST['uname'] ) );
     160        $passwrd = trim( stripslashes( $_POST['pwd'] ) );
     161        $dbhost  = trim( stripslashes( $_POST['dbhost'] ) );
     162        $prefix  = trim( stripslashes( $_POST['prefix'] ) );
     163
     164        $tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button">' . __( 'Try Again' ) . '</a>';
     165
     166        if ( empty( $prefix ) )
     167                wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) );
     168
    163169        // Validate $prefix: it can only contain letters, numbers and underscores
    164170        if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
    165                 wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' ) );
     171                wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) );
    166172
    167173        // Test the db connection.
    168174        /**#@+
     
    176182
    177183        // We'll fail here if the values are no good.
    178184        require_wp_db();
    179         if ( ! empty( $wpdb->error ) ) {
    180                 $back = '<p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button">' . __( 'Try Again' ) . '</a></p>';
    181                 wp_die( $wpdb->error->get_error_message() . $back );
    182         }
     185        if ( ! empty( $wpdb->error ) )
     186                wp_die( $wpdb->error->get_error_message() . $tryagain_link );
    183187
    184188        // Fetch or generate keys and salts.
    185189        $no_api = isset( $_POST['noapi'] );
     
    213217        $key = 0;
    214218        foreach ( $config_file as &$line ) {
    215219                if ( '$table_prefix  =' == substr( $line, 0, 16 ) ) {
    216                         $line = '$table_prefix  = \'' . $prefix . "';\r\n";
     220                        $line = '$table_prefix  = \'' . addcslashes( $prefix, "\\'" ) . "';\r\n";
    217221                        continue;
    218222                }
    219223
     
    228232                        case 'DB_USER'     :
    229233                        case 'DB_PASSWORD' :
    230234                        case 'DB_HOST'     :
    231                                 $line = "define('" . $constant . "'," . $padding . "'" . constant( $constant ) . "');\r\n";
     235                                $value = addcslashes( constant( $constant ), "\\'" );
     236                                $line = "define('" . $constant . "'," . $padding . "'" . $value . "');\r\n";
    232237                                break;
    233238                        case 'AUTH_KEY'         :
    234239                        case 'SECURE_AUTH_KEY'  :