jp (blog/edit): use utf-8-sig to decode content file to avoid BOM being propaged to content

This commit is contained in:
Goffi 2016-03-25 15:32:43 +01:00
commit f600da971e

View file

@ -330,7 +330,7 @@ class Edit(base.CommandBase, BlogCommon):
else:
# we can now send the blog
mb_data['content_rich'] = content.decode('utf-8')
mb_data['content_rich'] = content.decode('utf-8-sig') # we use utf-8-sig to avoid BOM
if item_ori_mb_data is not None:
mb_data['id'] = item_ori_mb_data['id']
@ -465,7 +465,7 @@ class Preview(base.CommandBase, BlogCommon):
def updateContent(self):
with open(self.content_file_path, 'rb') as f:
content = f.read().decode('utf-8')
content = f.read().decode('utf-8-sig')
if content and self.syntax != 'XHTML':
# we use safe=True because we want to have a preview as close as possible to what the
# people will see