mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 11:03:47 +03:00
Fix for an Issue #339
This commit is contained in:
parent
e835a2af9a
commit
a5a309212a
|
@ -48,6 +48,7 @@ from lib.core.threads import getCurrentThreadData
|
|||
from lib.core.threads import runThreads
|
||||
from lib.core.unescaper import unescaper
|
||||
from lib.request.connect import Connect as Request
|
||||
from lib.utils.xrange import xrange
|
||||
|
||||
def bisection(payload, expression, length=None, charsetType=None, firstChar=None, lastChar=None, dump=False):
|
||||
"""
|
||||
|
@ -197,9 +198,9 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
|
|||
return result
|
||||
|
||||
if charTbl is None:
|
||||
charTbl = list(asciiTbl)
|
||||
charTbl = type(asciiTbl)(asciiTbl)
|
||||
|
||||
originalTbl = list(charTbl)
|
||||
originalTbl = type(asciiTbl)(charTbl)
|
||||
|
||||
if continuousOrder and shiftTable is None:
|
||||
# Used for gradual expanding into unicode charspace
|
||||
|
@ -269,7 +270,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
|
|||
# list
|
||||
if expand and shiftTable:
|
||||
charTbl = xrange(maxChar + 1, (maxChar + 1) << shiftTable.pop())
|
||||
originalTbl = list(charTbl)
|
||||
originalTbl = xrange(charTbl)
|
||||
maxChar = maxValue = charTbl[-1]
|
||||
minChar = minValue = charTbl[0]
|
||||
else:
|
||||
|
|
75
lib/utils/xrange.py
Normal file
75
lib/utils/xrange.py
Normal file
|
@ -0,0 +1,75 @@
|
|||
class xrange(object):
|
||||
"""
|
||||
Advanced implementation of xrange (supports slice/copy/etc.)
|
||||
Reference: http://code.activestate.com/recipes/521885-a-pythonic-implementation-of-xrange/
|
||||
"""
|
||||
|
||||
__slots__ = ['_slice']
|
||||
|
||||
def __init__(self, *args):
|
||||
if args and isinstance(args[0], xrange):
|
||||
self._slice = slice(args[0].start, args[0].stop, args[0].step)
|
||||
else:
|
||||
self._slice = slice(*args)
|
||||
if self._slice.stop is None:
|
||||
# slice(*args) will never put None in stop unless it was
|
||||
# given as None explicitly.
|
||||
raise TypeError("xrange stop must not be None")
|
||||
|
||||
@property
|
||||
def start(self):
|
||||
if self._slice.start is not None:
|
||||
return self._slice.start
|
||||
return 0
|
||||
|
||||
@property
|
||||
def stop(self):
|
||||
return self._slice.stop
|
||||
|
||||
@property
|
||||
def step(self):
|
||||
if self._slice.step is not None:
|
||||
return self._slice.step
|
||||
return 1
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self._slice)
|
||||
|
||||
def __cmp__(self, other):
|
||||
return (cmp(type(self), type(other)) or
|
||||
cmp(self._slice, other._slice))
|
||||
|
||||
def __repr__(self):
|
||||
return '%s(%r, %r, %r)' % (self.__class__.__name__,
|
||||
self.start, self.stop, self.step)
|
||||
|
||||
def __len__(self):
|
||||
return self._len()
|
||||
|
||||
def _len(self):
|
||||
try:
|
||||
return max(0, int((self.stop - self.start) / self.step))
|
||||
except Exception, ex:
|
||||
import pdb
|
||||
pdb.set_trace()
|
||||
|
||||
def __getitem__(self, index):
|
||||
if isinstance(index, slice):
|
||||
start, stop, step = index.indices(self._len())
|
||||
return xrange(self._index(start),
|
||||
self._index(stop), step*self.step)
|
||||
elif isinstance(index, (int, long)):
|
||||
if index < 0:
|
||||
fixed_index = index + self._len()
|
||||
else:
|
||||
fixed_index = index
|
||||
|
||||
if not 0 <= fixed_index < self._len():
|
||||
raise IndexError("Index %d out of %r" % (index, self))
|
||||
|
||||
return self._index(fixed_index)
|
||||
else:
|
||||
raise TypeError("xrange indices must be slices or integers")
|
||||
|
||||
def _index(self, i):
|
||||
return self.start + self.step * i
|
Loading…
Reference in New Issue
Block a user