diff --git a/config.json b/config.json new file mode 100644 index 0000000000..51d656b777 --- /dev/null +++ b/config.json @@ -0,0 +1,40 @@ +{ + "base_template": "lib/website/templates/base.html", + "framework_version": "3.9.0", + "modules": { + "Calendar": { + "color": "#2980b9", + "icon": "icon-calendar", + "label": "Calendar", + "link": "Calendar/Event", + "type": "view" + }, + "Finder": { + "color": "#14C7DE", + "icon": "icon-folder-open", + "label": "Finder", + "link": "finder", + "type": "page" + }, + "Messages": { + "color": "#9b59b6", + "icon": "icon-comments", + "label": "Messages", + "link": "messages", + "type": "page" + }, + "To Do": { + "color": "#f1c40f", + "icon": "icon-check", + "label": "To Do", + "link": "todo", + "type": "page" + }, + "Website": { + "color": "#16a085", + "icon": "icon-globe", + "link": "website-home", + "type": "module" + } + } +} \ No newline at end of file diff --git a/webnotes/public/js/legacy/print_format.js b/webnotes/public/js/legacy/print_format.js index 4ed9be623e..b4bb3fe468 100644 --- a/webnotes/public/js/legacy/print_format.js +++ b/webnotes/public/js/legacy/print_format.js @@ -389,7 +389,7 @@ $.extend(_p, { lh = cstr(wn.boot.letter_heads[cur_frm.doc.letter_head]); } else if (cp.letter_head) { lh = cp.letter_head; - } + } return lh; }, diff --git a/webnotes/utils/__init__.py b/webnotes/utils/__init__.py index 78dc573559..1614f0c66c 100644 --- a/webnotes/utils/__init__.py +++ b/webnotes/utils/__init__.py @@ -5,9 +5,11 @@ from __future__ import unicode_literals from werkzeug.test import Client +import os +import re +import urllib import webnotes -import os no_value_fields = ['Section Break', 'Column Break', 'HTML', 'Table', 'FlexTable', 'Button', 'Image', 'Graph'] @@ -64,7 +66,6 @@ def extract_email_id(email): def validate_email_add(email_str): """Validates the email string""" email = extract_email_id(email_str) - import re return re.match("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", email.lower()) def get_request_site_address(full_address=False): @@ -277,7 +278,6 @@ def dict_to_str(args, sep='&'): """ Converts a dictionary to URL """ - import urllib t = [] for k in args.keys(): t.append(str(k)+'='+urllib.quote(str(args[k] or ''))) @@ -670,7 +670,6 @@ def strip_html(text): """ removes anything enclosed in and including <> """ - import re return re.compile(r'<.*?>').sub('', text) def escape_html(text): @@ -831,7 +830,6 @@ def get_url(uri=None): url = "http://" + subdomain if uri: - import urllib url = urllib.basejoin(url, uri) return url @@ -896,14 +894,26 @@ def get_disk_usage(): return 0 err, out = execute_in_shell("du -hsm {files_path}".format(files_path=files_path)) return cint(out.split("\n")[-2].split("\t")[0]) - -def expand_partial_links(html): - import re + +def scrub_urls(html): + html = expand_relative_urls(html) + html = quote_urls(html) + return html + +def expand_relative_urls(html): + # expand relative urls url = get_url() if not url.endswith("/"): url += "/" - return re.sub('(href|src){1}([\s]*=[\s]*[\'"]?)/*((?!http)[^\'" >]+)([\'"]?)', - '\g<1>\g<2>{}\g<3>\g<4>'.format(url), - html) + return re.sub('(href|src){1}([\s]*=[\s]*[\'"]?)((?!http)[^\'" >]+)([\'"]?)', + '\g<1>\g<2>{}\g<3>\g<4>'.format(url), html) + +def quote_urls(html): + def _quote_url(match): + groups = list(match.groups()) + groups[2] = urllib.quote(groups[2], safe="/:") + return "".join(groups) + return re.sub('(href|src){1}([\s]*=[\s]*[\'"]?)((?:http)[^\'">]+)([\'"]?)', + _quote_url, html) def touch_file(path): with open(path, 'a'): @@ -912,4 +922,4 @@ def touch_file(path): def get_test_client(): from webnotes.app import application - return Client(application) \ No newline at end of file + return Client(application) diff --git a/webnotes/utils/email_lib/bulk.py b/webnotes/utils/email_lib/bulk.py index cc89866543..928da58751 100644 --- a/webnotes/utils/email_lib/bulk.py +++ b/webnotes/utils/email_lib/bulk.py @@ -8,7 +8,7 @@ import urllib from webnotes.utils.email_lib.smtp import SMTPServer, send from webnotes.utils.email_lib.email_body import get_email, get_formatted_html from webnotes.utils.email_lib.html2text import html2text -from webnotes.utils import cint, get_url, expand_partial_links, nowdate +from webnotes.utils import cint, get_url, nowdate class BulkLimitCrossedError(webnotes.ValidationError): pass diff --git a/webnotes/utils/email_lib/email_body.py b/webnotes/utils/email_lib/email_body.py index a9b309e46e..4675277039 100644 --- a/webnotes/utils/email_lib/email_body.py +++ b/webnotes/utils/email_lib/email_body.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import expand_partial_links +from webnotes.utils import scrub_urls import email.utils from inlinestyler.utils import inline_css @@ -193,7 +193,7 @@ class EMail: return self.msg_root.as_string() def get_formatted_html(subject, message, footer=None): - message = expand_partial_links(message) + message = scrub_urls(message) return inline_css(webnotes.get_template("templates/emails/standard.html").render({ "content": message, diff --git a/webnotes/utils/email_lib/smtp.py b/webnotes/utils/email_lib/smtp.py index 707ddc5c34..3e0b4774a7 100644 --- a/webnotes/utils/email_lib/smtp.py +++ b/webnotes/utils/email_lib/smtp.py @@ -14,7 +14,6 @@ def send(email, as_bulk=False): webnotes.msgprint("Emails are muted") return - try: smtpserver = SMTPServer() if hasattr(smtpserver, "always_use_login_id_as_sender") and \