Make WordPress Core

Changeset 10597


Ignore:
Timestamp:
02/19/2009 07:01:57 PM (15 years ago)
Author:
ryan
Message:

Use real escape in environments that support it. see #5455

File:
1 edited

Legend:

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

    r9935 r10597  
    274274
    275275    /**
     276     * Whether to use mysql_real_escape_string
     277     *
     278     * @since 2.8.0
     279     * @access public
     280     * @var bool
     281     */
     282    var $real_escape = false;
     283
     284    /**
    276285     * Connects to the database server and selects a database
    277286     *
     
    334343
    335344        if ( $this->has_cap( 'collation' ) ) {
    336             $collation_query = '';
    337345            if ( !empty($this->charset) ) {
    338                 $collation_query = "SET NAMES '{$this->charset}'";
    339                 if (!empty($this->collate) )
    340                     $collation_query .= " COLLATE '{$this->collate}'";
     346                if ( function_exists('mysql_set_charset') ) {
     347                    mysql_set_charset($this->charset, $this->dbh);
     348                    $this->real_escape = true;
     349                } else {
     350                    $collation_query = "SET NAMES '{$this->charset}'";
     351                    if ( !empty($this->collate) )
     352                        $collation_query .= " COLLATE '{$this->collate}'";
     353                    $this->query($collation_query);
     354                }
    341355            }
    342 
    343             if ( !empty($collation_query) )
    344                 $this->query($collation_query);
    345 
    346356        }
    347357
     
    427437     */
    428438    function escape($string) {
    429         return addslashes( $string );
    430         // Disable rest for now, causing problems
    431         /*
    432         if( !$this->dbh || version_compare( phpversion(), '4.3.0' ) == '-1' )
    433             return mysql_escape_string( $string );
     439        if ( $this->dbh && $this->real_escape )
     440            return mysql_real_escape_string( $string, $this->dbh );
    434441        else
    435             return mysql_real_escape_string( $string, $this->dbh );
    436         */
     442            return addslashes( $string );
    437443    }
    438444
Note: See TracChangeset for help on using the changeset viewer.