Skip to content
Permalink
Browse files
don't crash on 'empty' wordpress posts (Issue #2263)
  • Loading branch information
ralsina committed Mar 7, 2016
1 parent 8ee888b commit a94dec2d1226321e5534b42a0ab4972abf6f49b9
Showing 2 changed files with 7 additions and 3 deletions.
@@ -16,6 +16,7 @@ Bugfixes
* Don’t display “Good link” messages in ``nikola check -l`` by default,
can be re-enabled with ``-v`` option (Issue #2268)
* Fix a format string in ``nikola check`` (Issue #2267)
* Don't crash wordpress importer when posts are "empty" (Issue #2263)

New in v7.7.6
=============
@@ -127,9 +127,12 @@ def transform_content(cls, content):
def write_content(cls, filename, content, rewrite_html=True):
"""Write content to file."""
if rewrite_html:
doc = html.document_fromstring(content)
doc.rewrite_links(replacer)
content = html.tostring(doc, encoding='utf8')
try:
doc = html.document_fromstring(content)
doc.rewrite_links(replacer)
content = html.tostring(doc, encoding='utf8')
except etree.ParserError:
content = content.encode('utf-8')
else:
content = content.encode('utf-8')

0 comments on commit a94dec2

Please sign in to comment.