comparison frontends/src/jp/cmd_blog.py @ 1929:b603a3d516d3

jp (blog/edit): use utf-8-sig to decode content file to avoid BOM being propaged to content
author Goffi <goffi@goffi.org>
date Fri, 25 Mar 2016 15:32:43 +0100
parents 03f780b60d5d
children 3e168cde7a7d eca59bc4e6c6
comparison
equal deleted inserted replaced
1928:6a8b26754f0d 1929:b603a3d516d3
328 meta_ori == mb_data): 328 meta_ori == mb_data):
329 self.disp(u"The content has not been modified, cancelling the blog edition") 329 self.disp(u"The content has not been modified, cancelling the blog edition")
330 330
331 else: 331 else:
332 # we can now send the blog 332 # we can now send the blog
333 mb_data['content_rich'] = content.decode('utf-8') 333 mb_data['content_rich'] = content.decode('utf-8-sig') # we use utf-8-sig to avoid BOM
334 334
335 if item_ori_mb_data is not None: 335 if item_ori_mb_data is not None:
336 mb_data['id'] = item_ori_mb_data['id'] 336 mb_data['id'] = item_ori_mb_data['id']
337 337
338 try: 338 try:
463 def updatePreviewExt(self): 463 def updatePreviewExt(self):
464 self._launchPreviewExt(self.update_cb_cmd, "blog_preview_update_cmd") 464 self._launchPreviewExt(self.update_cb_cmd, "blog_preview_update_cmd")
465 465
466 def updateContent(self): 466 def updateContent(self):
467 with open(self.content_file_path, 'rb') as f: 467 with open(self.content_file_path, 'rb') as f:
468 content = f.read().decode('utf-8') 468 content = f.read().decode('utf-8-sig')
469 if content and self.syntax != 'XHTML': 469 if content and self.syntax != 'XHTML':
470 # we use safe=True because we want to have a preview as close as possible to what the 470 # we use safe=True because we want to have a preview as close as possible to what the
471 # people will see 471 # people will see
472 content = self.host.bridge.syntaxConvert(content, self.syntax, 'XHTML', True, self.profile) 472 content = self.host.bridge.syntaxConvert(content, self.syntax, 'XHTML', True, self.profile)
473 473