diff --git a/frappe/utils/global_search.py b/frappe/utils/global_search.py index e945039d0d..f605c3bf66 100644 --- a/frappe/utils/global_search.py +++ b/frappe/utils/global_search.py @@ -10,6 +10,7 @@ import json import os from bs4 import BeautifulSoup from frappe.utils import cint, strip_html_tags +from frappe.utils.html_utils import unescape_html from frappe.model.base_document import get_controller from six import text_type @@ -345,11 +346,8 @@ def get_formatted_value(value, field): :return: """ - from six.moves.html_parser import HTMLParser - if getattr(field, 'fieldtype', None) in ["Text", "Text Editor"]: - h = HTMLParser() - value = h.unescape(frappe.safe_decode(value)) + value = unescape_html(frappe.safe_decode(value)) value = (re.subn(r'<[\s]*(script|style).*?(?s)', '', text_type(value))[0]) value = ' '.join(value.split()) return field.label + " : " + strip_html_tags(text_type(value)) diff --git a/frappe/utils/html_utils.py b/frappe/utils/html_utils.py index 6fdd383eb9..bccdbd9441 100644 --- a/frappe/utils/html_utils.py +++ b/frappe/utils/html_utils.py @@ -106,9 +106,8 @@ def get_icon_html(icon, small=False): return "".format(icon=icon) def unescape_html(value): - from six.moves.html_parser import HTMLParser - h = HTMLParser() - return h.unescape(value) + from html import unescape + return unescape(value) # adapted from https://raw.githubusercontent.com/html5lib/html5lib-python/4aa79f113e7486c7ec5d15a6e1777bfe546d3259/html5lib/sanitizer.py acceptable_elements = [