From 9df07891ff85cd93e4c65276752fbebad30313b6 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 6 Mar 2019 16:11:06 +0530 Subject: [PATCH] fix(xmlx): handle unparseable HTML --- frappe/utils/xlsxutils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frappe/utils/xlsxutils.py b/frappe/utils/xlsxutils.py index 17e5e7683a..9d9e35a023 100644 --- a/frappe/utils/xlsxutils.py +++ b/frappe/utils/xlsxutils.py @@ -61,10 +61,17 @@ def handle_html(data): obj = HTML2Text() obj.ignore_links = True obj.body_width = 0 - value = obj.handle(h) + + try: + value = obj.handle(h) + except Exception: + # unable to parse html, send it raw + return value + value = ", ".join(value.split(' \n')) value = " ".join(value.split('\n')) value = ", ".join(value.split('# ')) + return value def read_xlsx_file_from_attached_file(file_id=None, fcontent=None, filepath=None):