summaryrefslogtreecommitdiffstats
path: root/web/lib/aurjson.class.php
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2011-10-20 08:43:44 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2011-10-25 09:25:43 +0200
commite53b91fe52be262d94a45769814c1e87c796988b (patch)
tree7500e0c1aef89939d642e703f71d4c1c585fd832 /web/lib/aurjson.class.php
parent10b6a8fff7e6d407421c74889455b969be7f867f (diff)
downloadaur-e53b91fe52be262d94a45769814c1e87c796988b.tar.gz
aur-e53b91fe52be262d94a45769814c1e87c796988b.tar.xz
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 da2ebb667b7a332ddd8d905bf9b9a8694765fed6 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>
Diffstat (limited to 'web/lib/aurjson.class.php')
-rw-r--r--web/lib/aurjson.class.php3
1 files changed, 1 insertions, 2 deletions
diff --git a/web/lib/aurjson.class.php b/web/lib/aurjson.class.php
index edd6872e..6c7725c0 100644
--- a/web/lib/aurjson.class.php
+++ b/web/lib/aurjson.class.php
@@ -184,8 +184,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}%' )";