mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Escape wildcards in "LIKE" patterns
Percent signs ("%") and underscores ("_") are not escaped by
mysql_real_escape_string() and are interpreted as wildcards if combined
with "LIKE". Write a wrapper function db_escape_like() and use it where
appropriate.
Note that we already fixed this for the RPC interface in commit
da2ebb667b
but missed the other places.
This patch should fix all remaining flaws reported in FS#26527.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
323d418f02
commit
47c5167acb
4 changed files with 15 additions and 13 deletions
|
@ -195,8 +195,7 @@ class AurJSON {
|
|||
return $this->json_error('Query arg too small');
|
||||
}
|
||||
|
||||
$keyword_string = db_escape_string($keyword_string, $this->dbh);
|
||||
$keyword_string = addcslashes($keyword_string, '%_');
|
||||
$keyword_string = db_escape_like($keyword_string, $this->dbh);
|
||||
|
||||
$where_condition = "( Name LIKE '%{$keyword_string}%' OR " .
|
||||
"Description LIKE '%{$keyword_string}%' )";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue