From 001b77b5f32164bd4f5a447a84cb948cfa432d4c Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sun, 17 Feb 2019 16:45:45 -0800 Subject: [PATCH] better regex escaping --- applications/welcome/controllers/appadmin.py | 6 +++--- gluon/validators.py | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/applications/welcome/controllers/appadmin.py b/applications/welcome/controllers/appadmin.py index da050a5b..005285a5 100644 --- a/applications/welcome/controllers/appadmin.py +++ b/applications/welcome/controllers/appadmin.py @@ -185,9 +185,9 @@ def select(): is_imap = db._uri.startswith("imap://") except (KeyError, AttributeError, TypeError): is_imap = False - regex = re.compile('(?P\w+)\.(?P\w+)=(?P\d+)') + regex = re.compile(r'(?P
\w+)\.(?P\w+)=(?P\d+)') if len(request.args) > 1 and hasattr(db[request.args[1]], '_primarykey'): - regex = re.compile('(?P
\w+)\.(?P\w+)=(?P.+)') + regex = re.compile(r'(?P
\w+)\.(?P\w+)=(?P.+)') if request.vars.query: match = regex.match(request.vars.query) if match: @@ -237,7 +237,7 @@ def select(): tb = None if form.accepts(request.vars, formname=None): - regex = re.compile(request.args[0] + '\.(?P
\w+)\..+') + regex = re.compile(request.args[0] + r'\.(?P
\w+)\..+') match = regex.match(form.vars.query.strip()) if match: table = match.group('table') diff --git a/gluon/validators.py b/gluon/validators.py index f9b494e0..a9e47839 100644 --- a/gluon/validators.py +++ b/gluon/validators.py @@ -482,8 +482,8 @@ class IS_IN_SET(Validator): return (value, None) -regex1 = re.compile('\w+\.\w+') -regex2 = re.compile('%\(([^\)]+)\)\d*(?:\.\d+)?[a-zA-Z]') +regex1 = re.compile(r'\w+\.\w+') +regex2 = re.compile(r'%\(([^\)]+)\)\d*(?:\.\d+)?[a-zA-Z]') class IS_IN_DB(Validator): @@ -1157,7 +1157,7 @@ class IS_EMAIL(Validator): """ - body_regex = re.compile(''' + body_regex = re.compile(r''' ^(?!\.) # name may not begin with a dot ( [-a-z0-9!\#$%&'*+/=?^_`{|}~] # all legal characters except dot @@ -1166,7 +1166,7 @@ class IS_EMAIL(Validator): )+ (?