Skip to content

Commit 4ffe5ed

Browse files
committed
Remove excessive SQL quotes filtering adding risk to queries (done better) - refs BT#13285
1 parent 63438e7 commit 4ffe5ed

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

main/inc/lib/database.lib.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,12 @@ public static function escape_sql_wildcards($text)
248248
public static function escape_string($string)
249249
{
250250
$string = self::getManager()->getConnection()->quote($string);
251-
252-
return trim($string, "'");
251+
// The quote method from PDO also adds quotes around the string, which
252+
// is not how the legacy mysql_real_escape_string() was used in
253+
// Chamilo, so we need to remove the quotes around. Using trim will
254+
// remove more than one quote if they are sequenced, generating
255+
// broken queries and SQL injection risks
256+
return substr($string, 1, -1);
253257
}
254258

255259
/**

0 commit comments

Comments
 (0)