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

Skip to content

Commit 789dd6c

Browse files
committed
more quick fixes
1 parent af701cd commit 789dd6c

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

lib/core/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,10 @@ def safeStringFormat(formatStr, params):
10271027
return retVal
10281028

10291029
def sanitizeAsciiString(subject):
1030-
return "".join(char if ord(char) < 128 else '?' for char in subject)
1030+
retVal = None
1031+
if subject:
1032+
retVal = "".join(char if ord(char) < 128 else '?' for char in subject)
1033+
return retVal
10311034

10321035
def decloakToNamedTemporaryFile(filepath, name=None):
10331036
retVal = NamedTemporaryFile()

lib/request/connect.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,11 @@ def getPage(**kwargs):
203203
page = e.read()
204204
responseHeaders = e.info()
205205
except socket.timeout:
206+
page, responseHeaders = None, None
206207
warnMsg = "connection timed out while trying "
207208
warnMsg += "to get error page information"
208209
logger.warn(warnMsg)
209-
page, responseHeaders = None, None
210+
return None, None
210211
code = e.code
211212
status = e.msg
212213

@@ -249,15 +250,15 @@ def getPage(**kwargs):
249250
socket.setdefaulttimeout(conf.timeout)
250251

251252
page = sanitizeAsciiString(page)
252-
253253
parseResponse(page, responseHeaders)
254+
254255
responseMsg += "(%s - %d):\n" % (status, code)
255-
256+
256257
if conf.verbose <= 4:
257258
responseMsg += str(responseHeaders)
258259
elif conf.verbose > 4:
259260
responseMsg += "%s\n%s\n" % (responseHeaders, page)
260-
261+
261262
logger.log(8, responseMsg)
262263

263264
return page, responseHeaders

0 commit comments

Comments
 (0)