data-import: fix UnicodeEncodeError on data import in python2 (#6448)
why is this not built into re by default? Signed-off-by: Chinmay Pai <chinmaydpai@gmail.com>
This commit is contained in:
parent
8b08d1d5c5
commit
5f0dbecfed
2 changed files with 2 additions and 2 deletions
|
|
@ -76,6 +76,6 @@ def format_value(value, df=None, doc=None, currency=None, translated=False):
|
|||
|
||||
elif df.get("fieldtype") in ("Text", "Small Text"):
|
||||
if not re.search("(\<br|\<div|\<p)", value):
|
||||
return value.replace("\n", "<br>")
|
||||
return frappe.safe_decode(value).replace("\n", "<br>")
|
||||
|
||||
return value
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ def get_formatted_value(value, field):
|
|||
|
||||
if getattr(field, 'fieldtype', None) in ["Text", "Text Editor"]:
|
||||
h = HTMLParser()
|
||||
value = h.unescape(value)
|
||||
value = h.unescape(frappe.safe_decode(value))
|
||||
value = (re.subn(r'<[\s]*(script|style).*?</\1>(?s)', '', text_type(value))[0])
|
||||
value = ' '.join(value.split())
|
||||
return field.label + " : " + strip_html_tags(text_type(value))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue