[yum-git] Branch 'yum-3_2_X' - yum/sqlitesack.py

James Antill james at linux.duke.edu
Sat May 31 21:20:10 UTC 2008


 yum/sqlitesack.py |    3 +++
 1 file changed, 3 insertions(+)

New commits:
commit af9243770367e8337969738e30ec20bb5a2b7ea0
Author: James Antill <james at and.org>
Date:   Sat May 31 17:20:06 2008 -0400

    Allow searches with ' in them (need to escape other chars?). bug#240606

diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index f0617bb..7ab7eb0 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -512,6 +512,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
         if len(fields) < 1:
             return result
         
+        searchstring = searchstring.replace("'", "''")
         basestring="select DISTINCT pkgKey from packages where %s like '%%%s%%' " % (fields[0], searchstring)
         
         for f in fields[1:]:
@@ -537,6 +538,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
         if len(searchstrings) > constants.PATTERNS_MAX:
             tot = {}
             for searchstring in searchstrings:
+                searchstring = searchstring.replace("'", "''")
                 matches = self.searchPrimaryFields(fields, searchstring)
                 for po in matches:
                     tot[po] = tot.get(po, 0) + 1
@@ -553,6 +555,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
         selects = []
         
         for s in searchstrings:         
+            s = s.replace("'", "''")
             basestring="select pkgKey,1 AS cumul from packages where %s like '%%%s%%' " % (fields[0], s)
             for f in fields[1:]:
                 basestring = "%s or %s like '%%%s%%' " % (basestring, f, s)



More information about the Yum-cvs-commits mailing list