Skip to content
Snippets Groups Projects
Commit 0adffa59 authored by Radko Krkoš's avatar Radko Krkoš Committed by Pavel Kácha
Browse files

Server: Use raw strings for regexps in modify_client()

parent 05f01b67
No related branches found
No related tags found
No related merge requests found
...@@ -1505,7 +1505,7 @@ def modify_client(**kwargs): ...@@ -1505,7 +1505,7 @@ def modify_client(**kwargs):
return False return False
if hostname.endswith("."): # A single trailing dot is legal if hostname.endswith("."): # A single trailing dot is legal
hostname = hostname[:-1] # strip exactly one dot from the right, if present hostname = hostname[:-1] # strip exactly one dot from the right, if present
disallowed = re.compile("[^A-Z\d-]", re.IGNORECASE) disallowed = re.compile(r"[^A-Z\d-]", re.IGNORECASE)
return all( # Split by labels and verify individually return all( # Split by labels and verify individually
(label and len(label) <= 63 # length is within proper range (label and len(label) <= 63 # length is within proper range
and not label.startswith("-") and not label.endswith("-") # no bordering hyphens and not label.startswith("-") and not label.endswith("-") # no bordering hyphens
...@@ -1513,12 +1513,12 @@ def modify_client(**kwargs): ...@@ -1513,12 +1513,12 @@ def modify_client(**kwargs):
for label in hostname.split(".")) for label in hostname.split("."))
def isValidNSID(nsid): def isValidNSID(nsid):
allowed = re.compile("^(?:[a-zA-Z_][a-zA-Z0-9_]*\\.)*[a-zA-Z_][a-zA-Z0-9_]*$") allowed = re.compile(r"^(?:[a-zA-Z_][a-zA-Z0-9_]*\.)*[a-zA-Z_][a-zA-Z0-9_]*$")
return allowed.match(nsid) return allowed.match(nsid)
def isValidEmail(mail): def isValidEmail(mail):
mails = (email.utils.parseaddr(m) for m in mail.split(",")) mails = (email.utils.parseaddr(m) for m in mail.split(","))
allowed = re.compile("^[a-zA-Z0-9_.%!+-]+@[a-zA-Z0-9-.]+$") # just basic check allowed = re.compile(r"^[a-zA-Z0-9_.%!+-]+@[a-zA-Z0-9-.]+$") # just basic check
valid = (allowed.match(ms[1]) for ms in mails) valid = (allowed.match(ms[1]) for ms in mails)
return all(valid) return all(valid)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment