Bläddra i källkod

fix: Use raw string to avoid invalid sequence errors

Escaped when proven easier
version-14
Gavin D'souza 4 år sedan
förälder
incheckning
f6b215938a
3 ändrade filer med 6 tillägg och 6 borttagningar
  1. +1
    -1
      frappe/translate.py
  2. +1
    -1
      frappe/utils/__init__.py
  3. +4
    -4
      frappe/utils/data.py

+ 1
- 1
frappe/translate.py Visa fil

@@ -589,7 +589,7 @@ def is_translatable(m):
def add_line_number(messages, code): def add_line_number(messages, code):
ret = [] ret = []
messages = sorted(messages, key=lambda x: x[0]) messages = sorted(messages, key=lambda x: x[0])
newlines = [m.start() for m in re.compile('\\n').finditer(code)]
newlines = [m.start() for m in re.compile(r'\n').finditer(code)]
line = 1 line = 1
newline_i = 0 newline_i = 0
for pos, message, context in messages: for pos, message, context in messages:


+ 1
- 1
frappe/utils/__init__.py Visa fil

@@ -151,7 +151,7 @@ def split_emails(txt):


# emails can be separated by comma or newline # emails can be separated by comma or newline
s = re.sub(r'[\t\n\r]', ' ', cstr(txt)) s = re.sub(r'[\t\n\r]', ' ', cstr(txt))
for email in re.split('''[,\\n](?=(?:[^"]|"[^"]*")*$)''', s):
for email in re.split(r'[,\n](?=(?:[^"]|"[^"]*")*$)', s):
email = strip(cstr(email)) email = strip(cstr(email))
if email: if email:
email_list.append(email) email_list.append(email)


+ 4
- 4
frappe/utils/data.py Visa fil

@@ -454,7 +454,7 @@ def duration_to_seconds(duration):


def validate_duration_format(duration): def validate_duration_format(duration):
import re import re
is_valid_duration = re.match("^(?:(\d+d)?((^|\s)\d+h)?((^|\s)\d+m)?((^|\s)\d+s)?)$", duration)
is_valid_duration = re.match(r"^(?:(\d+d)?((^|\s)\d+h)?((^|\s)\d+m)?((^|\s)\d+s)?)$", duration)
if not is_valid_duration: if not is_valid_duration:
frappe.throw(frappe._("Value {0} must be in the valid duration format: d h m s").format(frappe.bold(duration))) frappe.throw(frappe._("Value {0} must be in the valid duration format: d h m s").format(frappe.bold(duration)))


@@ -1341,10 +1341,10 @@ def expand_relative_urls(html):


return "".join(to_expand) return "".join(to_expand)


html = re.sub('(href|src){1}([\s]*=[\s]*[\'"]?)((?!http)[^\'" >]+)([\'"]?)', _expand_relative_urls, html)
html = re.sub(r'(href|src){1}([\s]*=[\s]*[\'"]?)((?!http)[^\'" >]+)([\'"]?)', _expand_relative_urls, html)


# background-image: url('/assets/...') # background-image: url('/assets/...')
html = re.sub('(:[\s]?url)(\([\'"]?)((?!http)[^\'" >]+)([\'"]?\))', _expand_relative_urls, html)
html = re.sub(r'(:[\s]?url)(\([\'"]?)((?!http)[^\'" >]+)([\'"]?\))', _expand_relative_urls, html)
return html return html


def quoted(url): def quoted(url):
@@ -1355,7 +1355,7 @@ def quote_urls(html):
groups = list(match.groups()) groups = list(match.groups())
groups[2] = quoted(groups[2]) groups[2] = quoted(groups[2])
return "".join(groups) return "".join(groups)
return re.sub('(href|src){1}([\s]*=[\s]*[\'"]?)((?:http)[^\'">]+)([\'"]?)',
return re.sub(r'(href|src){1}([\s]*=[\s]*[\'"]?)((?:http)[^\'">]+)([\'"]?)',
_quote_url, html) _quote_url, html)


def unique(seq): def unique(seq):


Laddar…
Avbryt
Spara