From f2f49c0f2182f8fdc1ed60d6cb963c80d0dd840a Mon Sep 17 00:00:00 2001 From: Kevin Israel Date: Tue, 10 Jun 2014 15:51:33 -0400 Subject: [PATCH] Remove use of strencode() in buildLike() This may cause unnecessary backslashes (in the case of a literal % or _) to end up in the query when the DBMS uses C-style string escaping; however, the query should still work. Change-Id: I82681f83dd45fcbecf4bfd672f550cd4dba30949 --- includes/db/Database.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index 16e1ef231d..7bbcc2ffe4 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -2539,11 +2539,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * @return string */ protected function escapeLikeInternal( $s ) { - $s = str_replace( '\\', '\\\\', $s ); - $s = $this->strencode( $s ); - $s = str_replace( array( '%', '_' ), array( '\%', '\_' ), $s ); - - return $s; + return addcslashes( $s, '\%_' ); } /** @@ -2579,7 +2575,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { } } - return " LIKE '" . $s . "' "; + return " LIKE {$this->addQuotes( $s )} "; } /** -- 2.20.1