summaryrefslogtreecommitdiffstats
path: root/web/lib/aur.inc.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-24 17:57:54 +0200
commit47c5167acb0a4a2c809c03dc664fea1d130d0c8b (patch)
tree12a540a5885a59e478d8964de99605faa152c931 /web/lib/aur.inc.php
parent323d418f02074613241d65b9cabbfd65afea9abe (diff)
downloadaur-47c5167acb0a4a2c809c03dc664fea1d130d0c8b.tar.gz
aur-47c5167acb0a4a2c809c03dc664fea1d130d0c8b.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/aur.inc.php')
-rw-r--r--web/lib/aur.inc.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index e4e1cb57..ed0920f9 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -229,6 +229,11 @@ function db_escape_string($string) {
return mysql_real_escape_string($string);
}
+# Escape strings for usage in SQL LIKE operators.
+function db_escape_like($string) {
+ return addcslashes(mysql_real_escape_string($string), '%_');
+}
+
# disconnect from the database
# this won't normally be needed as PHP/reference counting will take care of
# closing the connection once it is no longer referenced