diff --git a/lib/core/common.py b/lib/core/common.py index d6d4e6678..e8b03a23b 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -1027,7 +1027,10 @@ def safeStringFormat(formatStr, params): return retVal def sanitizeAsciiString(subject): - return "".join(char if ord(char) < 128 else '?' for char in subject) + retVal = None + if subject: + retVal = "".join(char if ord(char) < 128 else '?' for char in subject) + return retVal def decloakToNamedTemporaryFile(filepath, name=None): retVal = NamedTemporaryFile() diff --git a/lib/request/connect.py b/lib/request/connect.py index 90d36d91b..e2ee9112f 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -203,10 +203,11 @@ class Connect: page = e.read() responseHeaders = e.info() except socket.timeout: + page, responseHeaders = None, None warnMsg = "connection timed out while trying " warnMsg += "to get error page information" logger.warn(warnMsg) - page, responseHeaders = None, None + return None, None code = e.code status = e.msg @@ -249,15 +250,15 @@ class Connect: socket.setdefaulttimeout(conf.timeout) page = sanitizeAsciiString(page) - parseResponse(page, responseHeaders) + responseMsg += "(%s - %d):\n" % (status, code) - + if conf.verbose <= 4: responseMsg += str(responseHeaders) elif conf.verbose > 4: responseMsg += "%s\n%s\n" % (responseHeaders, page) - + logger.log(8, responseMsg) return page, responseHeaders