@@ -38,6 +38,7 @@ def pivotDumpTable(table, colList, count=None, blind=True):
3838
3939 if count is None :
4040 query = dumpNode .count % table
41+ query = whereQuery (query )
4142 count = inject .getValue (query , union = False , error = False , expected = EXPECTED .INT , charsetType = CHARSET_TYPE .DIGITS ) if blind else inject .getValue (query , blind = False , time = False , expected = EXPECTED .INT )
4243
4344 if isinstance (count , basestring ) and count .isdigit ():
@@ -83,6 +84,7 @@ def pivotDumpTable(table, colList, count=None, blind=True):
8384 logger .info (infoMsg )
8485
8586 query = dumpNode .count2 % (column , table )
87+ query = whereQuery (query )
8688 value = inject .getValue (query , blind = blind , union = not blind , error = not blind , expected = EXPECTED .INT , charsetType = CHARSET_TYPE .DIGITS )
8789
8890 if isNumPosStrValue (value ):
@@ -122,6 +124,8 @@ def _(pivotValue):
122124 else :
123125 query = dumpNode .query2 .replace ("'%s'" , "%s" ) % (agent .preprocessField (table , column ), table , agent .preprocessField (table , colList [0 ]), unescaper .escape (pivotValue , False ))
124126
127+ query = whereQuery (query )
128+
125129 return unArrayizeValue (inject .getValue (query , blind = blind , time = blind , union = not blind , error = not blind ))
126130
127131 value = _ (pivotValue )
@@ -163,3 +167,18 @@ def _(pivotValue):
163167 logger .critical (errMsg )
164168
165169 return entries , lengths
170+
171+ def whereQuery (query ):
172+ if conf .dumpWhere and query :
173+ prefix , suffix = query .split (" ORDER BY " ) if " ORDER BY " in query else (query , "" )
174+
175+ if "%s)" % conf .tbl .upper () in prefix .upper ():
176+ prefix = re .sub (r"(?i)%s\)" % conf .tbl , "%s WHERE %s)" % (conf .tbl , conf .dumpWhere ), prefix )
177+ elif re .search (r"(?i)\bWHERE\b" , prefix ):
178+ prefix += " AND %s" % conf .dumpWhere
179+ else :
180+ prefix += " WHERE %s" % conf .dumpWhere
181+
182+ query = "%s ORDER BY %s" % (prefix , suffix ) if suffix else prefix
183+
184+ return query
0 commit comments