Просмотр исходного кода

fix: Use raw string to avoid invalid sequence errors

Escaped when proven easier
version-14
Gavin D'souza 4 лет назад
Родитель
Сommit
f6b215938a
3 измененных файлов: 6 добавлений и 6 удалений
  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 Просмотреть файл

@@ -589,7 +589,7 @@ def is_translatable(m):
def add_line_number(messages, code):
ret = []
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
newline_i = 0
for pos, message, context in messages:


+ 1
- 1
frappe/utils/__init__.py Просмотреть файл

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

# emails can be separated by comma or newline
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))
if email:
email_list.append(email)


+ 4
- 4
frappe/utils/data.py Просмотреть файл

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

def validate_duration_format(duration):
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:
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)

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/...')
html = re.sub('(:[\s]?url)(\([\'"]?)((?!http)[^\'" >]+)([\'"]?\))', _expand_relative_urls, html)
html = re.sub(r'(:[\s]?url)(\([\'"]?)((?!http)[^\'" >]+)([\'"]?\))', _expand_relative_urls, html)
return html

def quoted(url):
@@ -1355,7 +1355,7 @@ def quote_urls(html):
groups = list(match.groups())
groups[2] = quoted(groups[2])
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)

def unique(seq):


Загрузка…
Отмена
Сохранить