Make WordPress Core


Ignore:
Timestamp:
11/17/2015 06:12:08 AM (11 years ago)
Author:
pento
Message:

WPDB: Fall back to the connection charset when sanity checking strings.

If DB_CHARSET isn't defined (or is empty), wpdb::$charset will be empty, too. wpdb::strip_invalid_text() assumes that it isn't empty, however, so we need to fall back to the connection character set when we're running our sanity checks.

Fixes #34708.

File:
1 edited

Legend:

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

    r35544 r35655  
    28122812                    }
    28132813
     2814                    if ( $this->charset ) {
     2815                        $connection_charset = $this->charset;
     2816                    } else {
     2817                        if ( $this->use_mysqli ) {
     2818                            $connection_charset = mysqli_character_set_name( $this->dbh );
     2819                        } else {
     2820                            $connection_charset = mysql_client_encoding();
     2821                        }
     2822                    }
     2823
    28142824                    if ( is_array( $value['length'] ) ) {
    2815                         $queries[ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING $charset ), %.0f ) USING {$this->charset} )", $value['value'], $value['length']['length'] );
     2825                        $queries[ $col ] = $this->prepare( "CONVERT( LEFT( CONVERT( %s USING $charset ), %.0f ) USING $connection_charset )", $value['value'], $value['length']['length'] );
    28162826                    } else if ( 'binary' !== $charset ) {
    28172827                        // If we don't have a length, there's no need to convert binary - it will always return the same result.
    2818                         $queries[ $col ] = $this->prepare( "CONVERT( CONVERT( %s USING $charset ) USING {$this->charset} )", $value['value'] );
     2828                        $queries[ $col ] = $this->prepare( "CONVERT( CONVERT( %s USING $charset ) USING $connection_charset )", $value['value'] );
    28192829                    }
    28202830
Note: See TracChangeset for help on using the changeset viewer.