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 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:
@ -1706,12 +1706,18 @@ def getUnicode(value, encoding=None):
u'1'
"""
if isinstance(value, unicode):
return value
elif isinstance(value, basestring):
return unicode(value, encoding or UNICODE_ENCODING, errors="replace")
if not system:
if isinstance(value, unicode):
return value
elif isinstance(value, basestring):
return unicode(value, encoding or UNICODE_ENCODING, errors="replace")
else:
return unicode(value) # encoding ignored for non-basestring instances
else:
return unicode(value) # encoding ignored for non-basestring instances
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
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 getFileItems
from lib.core.common import getFileType
from lib.core.common import getUnicode
from lib.core.common import normalizePath
from lib.core.common import ntToPosixSlashes
from lib.core.common import openFile

View File

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

View File

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