mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Anchor returned regex to start and end of string
This commit is contained in:
parent
f9d6c677ea
commit
9fafdfa97d
@ -142,7 +142,9 @@ def log_failure(failure, msg, consumeErrors=True):
|
|||||||
|
|
||||||
|
|
||||||
def glob_to_regex(glob):
|
def glob_to_regex(glob):
|
||||||
"""Converts a glob to a compiled regex object
|
"""Converts a glob to a compiled regex object.
|
||||||
|
|
||||||
|
The regex is anchored at the beginning and end of the string.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
glob (str)
|
glob (str)
|
||||||
@ -158,4 +160,6 @@ def glob_to_regex(glob):
|
|||||||
res = res + '.'
|
res = res + '.'
|
||||||
else:
|
else:
|
||||||
res = res + re.escape(c)
|
res = res + re.escape(c)
|
||||||
return re.compile(res + "\\Z", re.IGNORECASE)
|
|
||||||
|
# \A anchors at start of string, \Z at end of string
|
||||||
|
return re.compile(r"\A" + res + r"\Z", re.IGNORECASE)
|
||||||
|
Loading…
Reference in New Issue
Block a user