more quick fixes

This commit is contained in:
Miroslav Stampar 2010-05-04 08:43:14 +00:00
parent af701cdaa2
commit 789dd6c66f
2 changed files with 9 additions and 5 deletions

View File

@ -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()

View File

@ -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