Allow HTML files with meta tags that don't have a "name" and "content" field to be read by the HTMLReader.

For example, "<meta charset="utf-8" />" might appear in an HTML document.  Without this change, this causes an exception.
This commit is contained in:
Richard Brooksby 2013-05-21 23:47:53 +01:00
commit 4fbf4b2638

View file

@ -270,12 +270,14 @@ class HTMLReader(Reader):
return result + '>'
def _handle_meta_tag(self, attrs):
name = self._attr_value(attrs, 'name').lower()
contents = self._attr_value(attrs, 'contents', '')
name = self._attr_value(attrs, 'name')
if name:
name = name.lower()
contents = self._attr_value(attrs, 'contents', '')
if name == 'keywords':
name = 'tags'
self.metadata[name] = contents
if name == 'keywords':
name = 'tags'
self.metadata[name] = contents
@classmethod
def _attr_value(cls, attrs, name, default=None):