mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 19:13:48 +03:00
minor refactoring
This commit is contained in:
parent
a2bb0d72e8
commit
6bb4dce3aa
|
@ -71,7 +71,7 @@ EXTRA ATTRIBUTES AND METHODS
|
||||||
"""
|
"""
|
||||||
from httplib import _CS_REQ_STARTED, _CS_REQ_SENT, _CS_IDLE, CannotSendHeader
|
from httplib import _CS_REQ_STARTED, _CS_REQ_SENT, _CS_IDLE, CannotSendHeader
|
||||||
|
|
||||||
from lib.core.common import encodeUnicode
|
from lib.core.convert import unicodeencode
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
@ -336,7 +336,7 @@ class HTTPConnection(httplib.HTTPConnection):
|
||||||
self._send_output()
|
self._send_output()
|
||||||
|
|
||||||
def send(self, str):
|
def send(self, str):
|
||||||
httplib.HTTPConnection.send(self, encodeUnicode(str, kb.pageEncoding))
|
httplib.HTTPConnection.send(self, unicodeencode(str, kb.pageEncoding))
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
##### TEST FUNCTIONS
|
##### TEST FUNCTIONS
|
||||||
|
|
|
@ -1799,22 +1799,6 @@ def getUnicode(value, encoding=None, system=False):
|
||||||
except:
|
except:
|
||||||
return getUnicode(value, UNICODE_ENCODING)
|
return getUnicode(value, UNICODE_ENCODING)
|
||||||
|
|
||||||
def encodeUnicode(value, encoding=None):
|
|
||||||
"""
|
|
||||||
Return 8-bit string representation of the supplied unicode value:
|
|
||||||
|
|
||||||
>>> encodeUnicode(u'test')
|
|
||||||
'test'
|
|
||||||
"""
|
|
||||||
|
|
||||||
retVal = value
|
|
||||||
if isinstance(value, unicode):
|
|
||||||
try:
|
|
||||||
retVal = value.encode(encoding or UNICODE_ENCODING)
|
|
||||||
except UnicodeEncodeError:
|
|
||||||
retVal = value.encode(UNICODE_ENCODING, errors="replace")
|
|
||||||
return retVal
|
|
||||||
|
|
||||||
# http://boredzo.org/blog/archives/2007-01-06/longest-common-prefix-in-python-2
|
# http://boredzo.org/blog/archives/2007-01-06/longest-common-prefix-in-python-2
|
||||||
def longestCommonPrefix(*sequences):
|
def longestCommonPrefix(*sequences):
|
||||||
if len(sequences) == 1:
|
if len(sequences) == 1:
|
||||||
|
|
|
@ -124,8 +124,24 @@ def urlencode(value, safe="%&=", convall=False, limit=False):
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def unicodeencode(value, encoding=None):
|
||||||
|
"""
|
||||||
|
Return 8-bit string representation of the supplied unicode value:
|
||||||
|
|
||||||
|
>>> unicodeencode(u'test')
|
||||||
|
'test'
|
||||||
|
"""
|
||||||
|
|
||||||
|
retVal = value
|
||||||
|
if isinstance(value, unicode):
|
||||||
|
try:
|
||||||
|
retVal = value.encode(encoding or UNICODE_ENCODING)
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
retVal = value.encode(UNICODE_ENCODING, errors="replace")
|
||||||
|
return retVal
|
||||||
|
|
||||||
def utf8encode(value):
|
def utf8encode(value):
|
||||||
return value.encode("utf-8")
|
return unicodeencode(value, "utf-8")
|
||||||
|
|
||||||
def utf8decode(value):
|
def utf8decode(value):
|
||||||
return value.decode("utf-8")
|
return value.decode("utf-8")
|
||||||
|
|
|
@ -21,7 +21,6 @@ from lib.core.common import average
|
||||||
from lib.core.common import calculateDeltaSeconds
|
from lib.core.common import calculateDeltaSeconds
|
||||||
from lib.core.common import clearConsoleLine
|
from lib.core.common import clearConsoleLine
|
||||||
from lib.core.common import cpuThrottle
|
from lib.core.common import cpuThrottle
|
||||||
from lib.core.common import encodeUnicode
|
|
||||||
from lib.core.common import extractRegexResult
|
from lib.core.common import extractRegexResult
|
||||||
from lib.core.common import getCurrentThreadData
|
from lib.core.common import getCurrentThreadData
|
||||||
from lib.core.common import getFilteredPageContent
|
from lib.core.common import getFilteredPageContent
|
||||||
|
@ -31,9 +30,10 @@ from lib.core.common import parseTargetUrl
|
||||||
from lib.core.common import readInput
|
from lib.core.common import readInput
|
||||||
from lib.core.common import removeReflectiveValues
|
from lib.core.common import removeReflectiveValues
|
||||||
from lib.core.common import stdev
|
from lib.core.common import stdev
|
||||||
from lib.core.common import wasLastRequestDelayed
|
|
||||||
from lib.core.convert import urlencode
|
|
||||||
from lib.core.common import urlEncodeCookieValues
|
from lib.core.common import urlEncodeCookieValues
|
||||||
|
from lib.core.common import wasLastRequestDelayed
|
||||||
|
from lib.core.convert import unicodeencode
|
||||||
|
from lib.core.convert import urlencode
|
||||||
from lib.core.data import conf
|
from lib.core.data import conf
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
from lib.core.data import logger
|
from lib.core.data import logger
|
||||||
|
@ -176,9 +176,9 @@ class Connect:
|
||||||
|
|
||||||
for key, item in headers.items():
|
for key, item in headers.items():
|
||||||
del headers[key]
|
del headers[key]
|
||||||
headers[encodeUnicode(key, kb.pageEncoding)] = encodeUnicode(item, kb.pageEncoding)
|
headers[unicodeencode(key, kb.pageEncoding)] = unicodeencode(item, kb.pageEncoding)
|
||||||
|
|
||||||
post = encodeUnicode(post, kb.pageEncoding)
|
post = unicodeencode(post, kb.pageEncoding)
|
||||||
|
|
||||||
if method:
|
if method:
|
||||||
req = MethodRequest(url, post, headers)
|
req = MethodRequest(url, post, headers)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user