This commit is contained in:
Miroslav Stampar 2015-10-29 16:52:17 +01:00
parent d41cd53d31
commit 0b64cf803c

View File

@ -17,6 +17,7 @@ from lib.core.common import extractErrorMessage
from lib.core.common import extractRegexResult from lib.core.common import extractRegexResult
from lib.core.common import getPublicTypeMembers from lib.core.common import getPublicTypeMembers
from lib.core.common import getUnicode from lib.core.common import getUnicode
from lib.core.common import randomStr
from lib.core.common import readInput from lib.core.common import readInput
from lib.core.common import resetCookieJar from lib.core.common import resetCookieJar
from lib.core.common import singleTimeLogMessage from lib.core.common import singleTimeLogMessage
@ -206,6 +207,15 @@ def checkCharEncoding(encoding, warn=True):
singleTimeLogMessage(warnMsg, logging.WARN, encoding) singleTimeLogMessage(warnMsg, logging.WARN, encoding)
encoding = None encoding = None
if encoding:
try:
unicode(randomStr(), encoding)
except:
if warn:
warnMsg = "invalid web page charset '%s'" % encoding
singleTimeLogMessage(warnMsg, logging.WARN, encoding)
encoding = None
return encoding return encoding
def getHeuristicCharEncoding(page): def getHeuristicCharEncoding(page):