From dc0748284b2cc2c90580b492180fac28f21cc451 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Wed, 6 May 2015 20:02:23 +0000 Subject: [PATCH] WPDB: When sanity checking query character sets, there's no need to check queries that don't return user data. Merges [32374] to the 4.1 branch. props pento. see #32104. Built from https://develop.svn.wordpress.org/branches/4.1@32402 git-svn-id: http://core.svn.wordpress.org/branches/4.1@32372 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/wp-db.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index a06493e8eb..5ac1027c3c 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -2502,7 +2502,7 @@ class wpdb { // We don't need to check the collation for queries that don't read data. $query = ltrim( $query, "\r\n\t (" ); - if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN)\s/i', $query ) ) { + if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN|CREATE)\s/i', $query ) ) { return true; } @@ -2713,6 +2713,12 @@ class wpdb { * @return string|WP_Error The converted query, or a {@see WP_Error} object if the conversion fails. */ protected function strip_invalid_text_from_query( $query ) { + // We don't need to check the collation for queries that don't read data. + $trimmed_query = ltrim( $query, "\r\n\t (" ); + if ( preg_match( '/^(?:SHOW|DESCRIBE|DESC|EXPLAIN|CREATE)\s/i', $trimmed_query ) ) { + return $query; + } + $table = $this->get_table_from_query( $query ); if ( $table ) { $charset = $this->get_table_charset( $table );