@@ -282,7 +282,7 @@ class DataExporter: | |||||
try: | try: | ||||
sflags = self.docs_to_export.get("flags", "I,U").upper() | sflags = self.docs_to_export.get("flags", "I,U").upper() | ||||
flags = 0 | flags = 0 | ||||
for a in re.split('\W+',sflags): | |||||
for a in re.split(r'\W+', sflags): | |||||
flags = flags | reflags.get(a,0) | flags = flags | reflags.get(a,0) | ||||
c = re.compile(names, flags) | c = re.compile(names, flags) | ||||
@@ -33,8 +33,7 @@ def execute(): | |||||
def scrub_relative_urls(html): | def scrub_relative_urls(html): | ||||
"""prepend a slash before a relative url""" | """prepend a slash before a relative url""" | ||||
try: | try: | ||||
return re.sub("""src[\s]*=[\s]*['"]files/([^'"]*)['"]""", 'src="/files/\g<1>"', html) | |||||
# return re.sub("""(src|href)[^\w'"]*['"](?!http|ftp|mailto|/|#|%|{|cid:|\.com/www\.)([^'" >]+)['"]""", '\g<1>="/\g<2>"', html) | |||||
return re.sub(r'src[\s]*=[\s]*[\'"]files/([^\'"]*)[\'"]', r'src="/files/\g<1>"', html) | |||||
except: | except: | ||||
print("Error", html) | print("Error", html) | ||||
raise | raise | ||||
@@ -78,7 +78,7 @@ def format_value(value, df=None, doc=None, currency=None, translated=False): | |||||
return "{}%".format(flt(value, 2)) | return "{}%".format(flt(value, 2)) | ||||
elif df.get("fieldtype") in ("Text", "Small Text"): | elif df.get("fieldtype") in ("Text", "Small Text"): | ||||
if not re.search("(\<br|\<div|\<p)", value): | |||||
if not re.search(r"(<br|<div|<p)", value): | |||||
return frappe.safe_decode(value).replace("\n", "<br>") | return frappe.safe_decode(value).replace("\n", "<br>") | ||||
elif df.get("fieldtype") == "Markdown Editor": | elif df.get("fieldtype") == "Markdown Editor": | ||||
@@ -39,7 +39,7 @@ class TestWebPage(unittest.TestCase): | |||||
published = 1, | published = 1, | ||||
content_type = 'Rich Text', | content_type = 'Rich Text', | ||||
main_section = 'rich text', | main_section = 'rich text', | ||||
main_section_md = '# h1\n\markdown content', | |||||
main_section_md = '# h1\nmarkdown content', | |||||
main_section_html = '<div>html content</div>' | main_section_html = '<div>html content</div>' | ||||
)).insert() | )).insert() | ||||