Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a3db3c0

Browse files
committed
str() -> unicode()
1 parent f24187f commit a3db3c0

17 files changed

Lines changed: 31 additions & 31 deletions

File tree

lib/controller/checks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def checkDynParam(place, parameter, value):
257257
logger.info(infoMsg)
258258

259259
randInt = randomInt()
260-
payload = agent.payload(place, parameter, value, str(randInt))
260+
payload = agent.payload(place, parameter, value, unicode(randInt))
261261
dynResult1 = Request.queryPage(payload, place)
262262

263263
if True == dynResult1:
@@ -395,7 +395,7 @@ def checkConnection():
395395
conf.seqMatcher.set_seq1(page)
396396

397397
except sqlmapConnectionException, errMsg:
398-
errMsg = str(errMsg)
398+
errMsg = unicode(errMsg)
399399
raise sqlmapConnectionException, errMsg
400400

401401
return True

lib/controller/controller.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def start():
155155

156156
if not conf.dropSetCookie:
157157
for _, cookie in enumerate(conf.cj):
158-
cookie = str(cookie)
158+
cookie = unicode(cookie)
159159
index = cookie.index(" for ")
160160

161161
cookieStr += "%s;" % cookie[8:index]
@@ -267,7 +267,7 @@ def start():
267267
action()
268268

269269
except exceptionsTuple, e:
270-
e = str(e)
270+
e = unicode(e)
271271

272272
if conf.multipleTargets:
273273
e += ", skipping to next url"

lib/core/common.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def readInput(message, default=None):
451451
message += "\n> "
452452

453453
if conf.batch and default:
454-
infoMsg = "%s%s" % (message, str(default))
454+
infoMsg = "%s%s" % (message, unicode(default))
455455
logger.info(infoMsg)
456456

457457
debugMsg = "used the default behaviour, running in batch mode"
@@ -517,7 +517,7 @@ def sanitizeStr(inpStr):
517517
@rtype: C{str}
518518
"""
519519

520-
cleanString = str(inpStr)
520+
cleanString = unicode(inpStr)
521521
cleanString = cleanString.replace("\n", " ").replace("\r", "")
522522

523523
return cleanString
@@ -638,8 +638,8 @@ def parseTargetDirect():
638638
conf.dbmsUser = details.group('user')
639639
conf.dbmsPass = details.group('pass')
640640
else:
641-
conf.dbmsUser = str()
642-
conf.dbmsPass = str()
641+
conf.dbmsUser = unicode()
642+
conf.dbmsPass = unicode()
643643

644644
if not conf.dbmsPass:
645645
conf.dbmsPass = None
@@ -1032,7 +1032,7 @@ def safeStringFormat(formatStr, params):
10321032

10331033
if index != -1:
10341034
if count < len(params):
1035-
retVal = retVal[:index] + str(params[count]) + retVal[index+2:]
1035+
retVal = retVal[:index] + unicode(params[count]) + retVal[index+2:]
10361036
else:
10371037
raise sqlmapNoneDataException, "wrong number of parameters during string formatting"
10381038
count += 1
@@ -1107,7 +1107,7 @@ def profile(profileOutputFile=None, dotOutputFile=None, imageOutputFile=None):
11071107
import gtk
11081108
import pydot
11091109
except ImportError, e:
1110-
errMsg = "profiling requires third-party libraries (%s)" % str(e)
1110+
errMsg = "profiling requires third-party libraries (%s)" % unicode(e)
11111111
logger.error(errMsg)
11121112
return
11131113

@@ -1343,7 +1343,7 @@ def getCommonStart(strings=[]):
13431343
if len(strings) == 1:
13441344
return strings[0]
13451345

1346-
retVal = str()
1346+
retVal = unicode()
13471347
maxCount = min(len(string) for string in strings)
13481348

13491349
count = 0

lib/core/dump.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def string(self, header, data, sort=True):
6363

6464
return
6565

66-
data = str(data)
66+
data = unicode(data)
6767

6868
if data:
6969
data = data.replace("__NEWLINE__", "\n").replace("__TAB__", "\t")
@@ -93,7 +93,7 @@ def lister(self, header, elements, sort=True):
9393
if isinstance(element, basestring):
9494
self.__write("[*] %s" % element)
9595
elif isinstance(element, (list, tuple, set)):
96-
self.__write("[*] " + ", ".join(str(e) for e in element))
96+
self.__write("[*] " + ", ".join(unicode(e) for e in element))
9797

9898
if elements:
9999
self.__write("")

lib/core/progress.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def update(self, newAmount=0):
8080
" " * (allFull - numHashes))
8181

8282
# Add the percentage at the beginning of the progress bar
83-
percentString = str(percentDone) + "%"
83+
percentString = unicode(percentDone) + "%"
8484
self.__progBar = "%s %s" % (percentString, self.__progBar)
8585

8686
def draw(self, eta=0):
@@ -102,4 +102,4 @@ def __str__(self):
102102
This method returns the progress bar string
103103
"""
104104

105-
return str(self.__progBar)
105+
return unicode(self.__progBar)

lib/core/update.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def __updateSqlmap():
214214
logger.debug(debugMsg)
215215

216216
def notify(event_dict):
217-
action = str(event_dict['action'])
217+
action = unicode(event_dict['action'])
218218
index = action.find('_')
219219
prefix = action[index + 1].upper() if index != -1 else action.capitalize()
220220

@@ -224,7 +224,7 @@ def notify(event_dict):
224224
if action.find('_completed') == -1:
225225
print "%s\t%s" % (prefix, event_dict['path'])
226226
else:
227-
revision = str(event_dict['revision'])
227+
revision = unicode(event_dict['revision'])
228228
index = revision.find('number ')
229229

230230
if index != -1:

lib/request/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def decodePage(page, encoding):
9494
Decode gzip/deflate HTTP response
9595
"""
9696

97-
if str(encoding).lower() in ('gzip', 'x-gzip', 'deflate'):
97+
if unicode(encoding).lower() in (u'gzip', u'x-gzip', u'deflate'):
9898
if encoding == 'deflate':
9999
# http://stackoverflow.com/questions/1089662/python-inflate-and-deflate-implementations
100100
data = StringIO.StringIO(zlib.decompress(page, -15))

lib/request/connect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def getPage(**kwargs):
163163
if not cookieStr:
164164
cookieStr = "Cookie: "
165165

166-
cookie = str(cookie)
166+
cookie = unicode(cookie)
167167
index = cookie.index(" for ")
168168

169169
cookieStr += "%s; " % cookie[8:index]
@@ -257,7 +257,7 @@ def getPage(**kwargs):
257257
responseMsg += "(%s - %d):\n" % (status, code)
258258

259259
if conf.verbose <= 4:
260-
responseMsg += str(responseHeaders)
260+
responseMsg += unicode(responseHeaders)
261261
elif conf.verbose > 4:
262262
responseMsg += "%s\n%s\n" % (responseHeaders, page)
263263

lib/request/direct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def direct(query, content=True):
5454
output = base64unpickle(kb.resumedQueries[conf.hostname][query][:-1])
5555

5656
infoMsg = "resumed from file '%s': " % conf.sessionFile
57-
infoMsg += "%s..." % str(output)[:20]
57+
infoMsg += "%s..." % unicode(output)[:20]
5858
logger.info(infoMsg)
5959
elif select:
6060
output = timeout(func=conf.dbmsConnector.select, args=(query,), duration=conf.timeout, default=None)
@@ -67,7 +67,7 @@ def direct(query, content=True):
6767

6868
if len(output) == 1:
6969
if len(output[0]) == 1:
70-
return str(list(output)[0][0])
70+
return unicode(list(output)[0][0])
7171
else:
7272
return list(output)
7373
else:

lib/takeover/metasploit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __skeletonSelection(self, msg, lst=None, maxValue=1, default=1):
156156

157157
if not choice:
158158
if lst:
159-
choice = str(default)
159+
choice = unicode(default)
160160
else:
161161
return default
162162

0 commit comments

Comments
 (0)