compile regext outside of routes
parent
4ba413eaa9
commit
470b046702
|
@ -96,6 +96,10 @@ color_regex = re.compile("[a-z0-9]{6}", flags=re.A)
|
|||
|
||||
showmore_regex = re.compile("(.{3000,40000}?</p>)(<p>.*)", flags=re.A)
|
||||
|
||||
search_token_regex = re.compile('"([^"]*)"|(\S+)', flags=re.A)
|
||||
|
||||
git_regex = re.compile("ref: (refs/.+)", flags=re.A)
|
||||
|
||||
def sub_matcher(match, upper=False):
|
||||
if match.group(0).startswith('<'):
|
||||
return match.group(0)
|
||||
|
|
|
@ -493,7 +493,7 @@ def admin_git_head():
|
|||
try:
|
||||
with open('.git/HEAD', encoding='utf_8') as head_f:
|
||||
head_txt = head_f.read()
|
||||
head_path = re.match('ref: (refs/.+)', head_txt).group(1)
|
||||
head_path = git_regex.match(head_txt).group(1)
|
||||
with open('.git/' + head_path, encoding='utf_8') as ref_f:
|
||||
gitref = ref_f.read()[0:short_len]
|
||||
except:
|
||||
|
|
|
@ -24,10 +24,9 @@ def searchparse(text):
|
|||
text = text.replace(f"{x}:{criteria[x]}", "")
|
||||
|
||||
text = text.strip()
|
||||
re_search_token = re.compile('"([^"]*)"|(\S+)')
|
||||
if text:
|
||||
criteria['q'] = []
|
||||
for m in re_search_token.finditer(text):
|
||||
for m in search_token_regex.finditer(text):
|
||||
token = m[1] if m[1] else m[2]
|
||||
# Escape SQL pattern matching special characters
|
||||
token = token.replace('\\', '').replace('_', '\_').replace('%', '\%')
|
||||
|
|
Loading…
Reference in New Issue