From e6de92ce885f86205ab4935d26a32eab8f937ac6 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Mon, 15 Dec 2014 13:36:08 +0100 Subject: [PATCH] Minor patch (unicode related) --- lib/controller/checks.py | 2 +- lib/core/common.py | 2 +- lib/core/target.py | 4 ++-- lib/parse/configfile.py | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/controller/checks.py b/lib/controller/checks.py index aa6859c54..f2afacd4a 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -1273,7 +1273,7 @@ def checkConnection(suppressOutput=False): raise SqlmapConnectionException(errMsg) except socket.error, ex: errMsg = "problem occurred while " - errMsg += "resolving a host name '%s' ('%s')" % (conf.hostname, str(ex)) + errMsg += "resolving a host name '%s' ('%s')" % (conf.hostname, getUnicode(ex)) raise SqlmapConnectionException(errMsg) if not suppressOutput and not conf.dummy: diff --git a/lib/core/common.py b/lib/core/common.py index 03261478f..457d1b048 100755 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -857,7 +857,7 @@ def dataToDumpFile(dumpFile, data): dumpFile.write(data) dumpFile.flush() except IOError, ex: - if "No space left" in str(ex): + if "No space left" in getUnicode(ex): errMsg = "no space left on output device" logger.error(errMsg) else: diff --git a/lib/core/target.py b/lib/core/target.py index 7ba192a5c..8e5e32eaf 100644 --- a/lib/core/target.py +++ b/lib/core/target.py @@ -225,7 +225,7 @@ def _setRequestParams(): elif test[0] in ("q", "Q"): raise SqlmapUserQuitException - for place, value in ((PLACE.URI, conf.url), (PLACE.CUSTOM_POST, conf.data), (PLACE.CUSTOM_HEADER, unicode(conf.httpHeaders))): + for place, value in ((PLACE.URI, conf.url), (PLACE.CUSTOM_POST, conf.data), (PLACE.CUSTOM_HEADER, getUnicode(conf.httpHeaders))): _ = re.sub(PROBLEMATIC_CUSTOM_INJECTION_PATTERNS, "", value or "") if place == PLACE.CUSTOM_HEADER else value or "" if CUSTOM_INJECTION_MARK_CHAR in _: if kb.processUserMarks is None: @@ -610,7 +610,7 @@ def _createTargetDirs(): if conf.data: f.write("\n\n%s" % getUnicode(conf.data)) except IOError, ex: - if "denied" in str(ex): + if "denied" in getUnicode(ex): errMsg = "you don't have enough permissions " else: errMsg = "something went wrong while trying " diff --git a/lib/parse/configfile.py b/lib/parse/configfile.py index 7f899398b..24e6aadb5 100644 --- a/lib/parse/configfile.py +++ b/lib/parse/configfile.py @@ -11,6 +11,7 @@ from ConfigParser import MissingSectionHeaderError from ConfigParser import ParsingError from lib.core.common import checkFile +from lib.core.common import getUnicode from lib.core.common import openFile from lib.core.common import unArrayizeValue from lib.core.common import UnicodeRawConfigParser @@ -41,7 +42,7 @@ def configFileProxy(section, option, boolean=False, integer=False): value = config.get(section, option) except ValueError, ex: errMsg = "error occurred while processing the option " - errMsg += "'%s' in provided configuration file ('%s')" % (option, str(ex)) + errMsg += "'%s' in provided configuration file ('%s')" % (option, getUnicode(ex)) raise SqlmapSyntaxException(errMsg) if value: @@ -72,7 +73,7 @@ def configFileParser(configFile): config = UnicodeRawConfigParser() config.readfp(configFP) except Exception, ex: - errMsg = "you have provided an invalid and/or unreadable configuration file ('%s')" % str(ex) + errMsg = "you have provided an invalid and/or unreadable configuration file ('%s')" % getUnicode(ex) raise SqlmapSyntaxException(errMsg) if not config.has_section("Target"):