Skip to content

Commit a94dec2

Browse files
committedMar 7, 2016
don't crash on 'empty' wordpress posts (Issue #2263)
1 parent 8ee888b commit a94dec2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
 

Diff for: ‎CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Bugfixes
1616
* Don’t display “Good link” messages in ``nikola check -l`` by default,
1717
can be re-enabled with ``-v`` option (Issue #2268)
1818
* Fix a format string in ``nikola check`` (Issue #2267)
19+
* Don't crash wordpress importer when posts are "empty" (Issue #2263)
1920

2021
New in v7.7.6
2122
=============

Diff for: ‎nikola/plugins/basic_import.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,12 @@ def transform_content(cls, content):
127127
def write_content(cls, filename, content, rewrite_html=True):
128128
"""Write content to file."""
129129
if rewrite_html:
130-
doc = html.document_fromstring(content)
131-
doc.rewrite_links(replacer)
132-
content = html.tostring(doc, encoding='utf8')
130+
try:
131+
doc = html.document_fromstring(content)
132+
doc.rewrite_links(replacer)
133+
content = html.tostring(doc, encoding='utf8')
134+
except etree.ParserError:
135+
content = content.encode('utf-8')
133136
else:
134137
content = content.encode('utf-8')
135138

0 commit comments

Comments
 (0)
Please sign in to comment.