- if content and is_html:
- parser = parse_html(content, charset, self.log)
+ content_stripped = content.strip()
+ if content_stripped and charset:
+ try:
+ content_stripped = content_stripped.decode(
+ charset, 'replace')
+ except LookupError:
+ charset = None
+ self.log(" unknown charset "
+ "in Content-Type header")
+ if content_stripped and is_html:
+ parser = parse_html(
+ content_stripped, charset, self.log)
+ if charset:
+ bookmark.charset = charset
+ elif parser and parser.meta_charset:
+ bookmark.charset = parser.meta_charset