fix regarding bug report from andyroyalbattle@yahoo.it

This commit is contained in:
Miroslav Stampar 2011-03-18 16:26:39 +00:00
parent 4e300baaf2
commit 00b9d85ffc
4 changed files with 16 additions and 12 deletions

View File

@ -1694,7 +1694,7 @@ def getPartRun():
# Return the INI tag to consider for common outputs (e.g. 'Databases') # Return the INI tag to consider for common outputs (e.g. 'Databases')
return commonPartsDict[retVal][1] if retVal in commonPartsDict else retVal return commonPartsDict[retVal][1] if retVal in commonPartsDict else retVal
def getUnicode(value, encoding=None): def getUnicode(value, encoding=None, system=False):
""" """
Return the unicode representation of the supplied value: Return the unicode representation of the supplied value:
@ -1706,12 +1706,18 @@ def getUnicode(value, encoding=None):
u'1' u'1'
""" """
if not system:
if isinstance(value, unicode): if isinstance(value, unicode):
return value return value
elif isinstance(value, basestring): elif isinstance(value, basestring):
return unicode(value, encoding or UNICODE_ENCODING, errors="replace") return unicode(value, encoding or UNICODE_ENCODING, errors="replace")
else: else:
return unicode(value) # encoding ignored for non-basestring instances return unicode(value) # encoding ignored for non-basestring instances
else:
try:
return getUnicode(value, sys.getfilesystemencoding() or sys.stdin.encoding)
except:
return getUnicode(value, UNICODE_ENCODING)
# 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):

View File

@ -30,7 +30,6 @@ from lib.core.common import extractRegexResult
from lib.core.common import getConsoleWidth from lib.core.common import getConsoleWidth
from lib.core.common import getFileItems from lib.core.common import getFileItems
from lib.core.common import getFileType from lib.core.common import getFileType
from lib.core.common import getUnicode
from lib.core.common import normalizePath from lib.core.common import normalizePath
from lib.core.common import ntToPosixSlashes from lib.core.common import ntToPosixSlashes
from lib.core.common import openFile from lib.core.common import openFile

View File

@ -68,6 +68,7 @@ def update():
client = pysvn.Client() client = pysvn.Client()
client.callback_notify = notify client.callback_notify = notify
client.update(rootDir) client.update(rootDir)
except ImportError, _: except ImportError, _:
debugMsg = "sqlmap will try to update itself using 'svn' command" debugMsg = "sqlmap will try to update itself using 'svn' command"
logger.debug(debugMsg) logger.debug(debugMsg)
@ -79,8 +80,9 @@ def update():
svnStdout, svnStderr = process.communicate() svnStdout, svnStderr = process.communicate()
if svnStderr: if svnStderr:
errMsg = svnStderr.strip() errMsg = getUnicode(svnStderr, system=True).strip()
logger.error(errMsg) logger.error(errMsg)
elif svnStdout: elif svnStdout:
revision = re.search("revision\s+([\d]+)", svnStdout, re.I) revision = re.search("revision\s+([\d]+)", svnStdout, re.I)

View File

@ -536,10 +536,7 @@ def cmdLineParser():
args = [] args = []
for arg in sys.argv: for arg in sys.argv:
try: args.append(getUnicode(arg, system=True))
args.append(getUnicode(arg, sys.getfilesystemencoding() or sys.stdin.encoding))
except:
args.append(getUnicode(arg, UNICODE_ENCODING))
(args, _) = parser.parse_args(args) (args, _) = parser.parse_args(args)