Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
don't crash on 'empty' wordpress posts (Issue #2263)
  • Loading branch information
ralsina committed Mar 7, 2016
1 parent 8ee888b commit a94dec2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -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
=============
Expand Down
9 changes: 6 additions & 3 deletions nikola/plugins/basic_import.py
Expand Up @@ -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')

Expand Down

0 comments on commit a94dec2

Please sign in to comment.