Check that charset is not None before lowering it in set_encoding().

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3547 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2007-03-21 19:32:19 +00:00
parent 61083d6a36
commit 9de237b4c2

View file

@ -208,6 +208,7 @@ def resolve_entities (s):
"""
return _entity_re.sub(_resolve_entity, s)
SUPPORTED_CHARSETS = ["utf-8", "iso-8859-1", "iso-8859-15"]
_encoding_ro = re.compile(r"charset=(?P<encoding>[-0-9a-zA-Z]+)")
@ -223,7 +224,7 @@ def set_encoding (parsobj, attrs):
if attrs.get_true('http-equiv', u'').lower() == u"content-type":
charset = attrs.get_true('content', u'')
charset = get_ctype_charset(charset.encode('ascii', 'ignore'))
if charset is not None:
if charset and charset.lower() in SUPPORTED_CHARSETS:
parsobj.encoding = charset